From 58b186895099127ddc15ab705031aa8d738f5aad Mon Sep 17 00:00:00 2001 From: Kumar Abhinav <133813093+Abhinav0905@users.noreply.github.com> Date: Tue, 27 Oct 2026 13:05:25 -0700 Subject: [PATCH] Regenerate Python clients with shared legacy model helpers Pin OpenAPI Generator to the merged helper deduplication change and regenerate both clients from the existing Kubernetes schema. Preserve Kubernetes patches, add serialization compatibility tests, and make package size comparisons reproducible. Related to kubernetes-client/python#2677. --- devel/measure-package-size.py | 78 ++ kubernetes/.openapi-generator/COMMIT | 4 +- kubernetes/.openapi-generator/FILES | 1 + kubernetes/.openapi-generator/VERSION | 2 +- kubernetes/README.md | 40 +- kubernetes/aio/.openapi-generator/COMMIT | 4 +- kubernetes/aio/.openapi-generator/FILES | 1 + kubernetes/aio/.openapi-generator/VERSION | 2 +- kubernetes/aio/README.md | 40 +- .../aio/client/_legacy_model_helpers.py | 80 ++ .../client/api/admissionregistration_api.py | 4 +- .../api/admissionregistration_v1_api.py | 212 ++-- .../api/admissionregistration_v1alpha1_api.py | 68 +- .../api/admissionregistration_v1beta1_api.py | 68 +- .../aio/client/api/apiextensions_api.py | 4 +- .../aio/client/api/apiextensions_v1_api.py | 52 +- .../aio/client/api/apiregistration_api.py | 4 +- .../aio/client/api/apiregistration_v1_api.py | 52 +- kubernetes/aio/client/api/apis_api.py | 4 +- kubernetes/aio/client/api/apps_api.py | 4 +- kubernetes/aio/client/api/apps_v1_api.py | 296 +++--- .../aio/client/api/authentication_api.py | 4 +- .../aio/client/api/authentication_v1_api.py | 12 +- .../aio/client/api/authorization_api.py | 4 +- .../aio/client/api/authorization_v1_api.py | 20 +- kubernetes/aio/client/api/autoscaling_api.py | 4 +- .../aio/client/api/autoscaling_v1_api.py | 56 +- .../aio/client/api/autoscaling_v2_api.py | 56 +- kubernetes/aio/client/api/batch_api.py | 4 +- kubernetes/aio/client/api/batch_v1_api.py | 108 +- kubernetes/aio/client/api/certificates_api.py | 4 +- .../aio/client/api/certificates_v1_api.py | 152 +-- .../client/api/certificates_v1beta1_api.py | 88 +- kubernetes/aio/client/api/coordination_api.py | 4 +- .../aio/client/api/coordination_v1_api.py | 40 +- .../client/api/coordination_v1alpha2_api.py | 40 +- .../client/api/coordination_v1beta1_api.py | 40 +- kubernetes/aio/client/api/core_api.py | 4 +- kubernetes/aio/client/api/core_v1_api.py | 928 +++++++++--------- .../aio/client/api/custom_objects_api.py | 136 +-- kubernetes/aio/client/api/discovery_api.py | 4 +- kubernetes/aio/client/api/discovery_v1_api.py | 40 +- kubernetes/aio/client/api/events_api.py | 4 +- kubernetes/aio/client/api/events_v1_api.py | 40 +- .../client/api/flowcontrol_apiserver_api.py | 4 +- .../api/flowcontrol_apiserver_v1_api.py | 100 +- .../aio/client/api/internal_apiserver_api.py | 4 +- .../api/internal_apiserver_v1alpha1_api.py | 52 +- kubernetes/aio/client/api/lifecycle_api.py | 4 +- .../aio/client/api/lifecycle_v1alpha1_api.py | 108 +- kubernetes/aio/client/api/logs_api.py | 4 +- kubernetes/aio/client/api/networking_api.py | 4 +- .../aio/client/api/networking_v1_api.py | 204 ++-- kubernetes/aio/client/api/node_api.py | 4 +- kubernetes/aio/client/api/node_v1_api.py | 36 +- kubernetes/aio/client/api/openid_api.py | 4 +- kubernetes/aio/client/api/policy_api.py | 4 +- kubernetes/aio/client/api/policy_v1_api.py | 56 +- .../aio/client/api/rbac_authorization_api.py | 4 +- .../client/api/rbac_authorization_v1_api.py | 140 +-- kubernetes/aio/client/api/resource_api.py | 4 +- kubernetes/aio/client/api/resource_v1_api.py | 204 ++-- .../aio/client/api/resource_v1alpha3_api.py | 100 +- .../aio/client/api/resource_v1beta1_api.py | 156 +-- .../aio/client/api/resource_v1beta2_api.py | 204 ++-- kubernetes/aio/client/api/scheduling_api.py | 4 +- .../aio/client/api/scheduling_v1_api.py | 36 +- .../aio/client/api/scheduling_v1alpha3_api.py | 144 +-- .../aio/client/api/scheduling_v1beta1_api.py | 92 +- kubernetes/aio/client/api/storage_api.py | 4 +- kubernetes/aio/client/api/storage_v1_api.py | 232 ++--- .../aio/client/api/storagemigration_api.py | 4 +- .../aio/client/api/storagemigration_v1_api.py | 52 +- .../api/storagemigration_v1beta1_api.py | 52 +- kubernetes/aio/client/api/version_api.py | 4 +- kubernetes/aio/client/api/well_known_api.py | 4 +- kubernetes/aio/client/api_client.py | 87 +- ...issionregistration_v1_service_reference.py | 72 +- ...onregistration_v1_webhook_client_config.py | 72 +- .../apiextensions_v1_service_reference.py | 72 +- .../apiextensions_v1_webhook_client_config.py | 72 +- .../apiregistration_v1_service_reference.py | 72 +- .../models/authentication_v1_token_request.py | 72 +- .../client/models/core_v1_endpoint_port.py | 72 +- kubernetes/aio/client/models/core_v1_event.py | 72 +- .../aio/client/models/core_v1_event_list.py | 72 +- .../aio/client/models/core_v1_event_series.py | 72 +- .../client/models/core_v1_resource_claim.py | 72 +- .../models/discovery_v1_endpoint_port.py | 72 +- .../aio/client/models/events_v1_event.py | 72 +- .../aio/client/models/events_v1_event_list.py | 72 +- .../client/models/events_v1_event_series.py | 72 +- .../client/models/flowcontrol_v1_subject.py | 72 +- .../aio/client/models/rbac_v1_subject.py | 72 +- .../models/resource_v1_resource_claim.py | 72 +- .../client/models/storage_v1_token_request.py | 72 +- kubernetes/aio/client/models/v1_affinity.py | 72 +- .../aio/client/models/v1_aggregation_rule.py | 72 +- .../models/v1_allocated_device_status.py | 72 +- .../aio/client/models/v1_allocation_result.py | 72 +- kubernetes/aio/client/models/v1_api_group.py | 72 +- .../aio/client/models/v1_api_group_list.py | 72 +- .../aio/client/models/v1_api_resource.py | 72 +- .../aio/client/models/v1_api_resource_list.py | 72 +- .../aio/client/models/v1_api_service.py | 72 +- .../client/models/v1_api_service_condition.py | 72 +- .../aio/client/models/v1_api_service_list.py | 72 +- .../aio/client/models/v1_api_service_spec.py | 72 +- .../client/models/v1_api_service_status.py | 72 +- .../aio/client/models/v1_api_versions.py | 72 +- .../aio/client/models/v1_app_armor_profile.py | 72 +- .../client/models/v1_apply_configuration.py | 72 +- .../aio/client/models/v1_attached_volume.py | 72 +- .../aio/client/models/v1_audit_annotation.py | 72 +- ...1_aws_elastic_block_store_volume_source.py | 72 +- .../models/v1_azure_disk_volume_source.py | 72 +- .../v1_azure_file_persistent_volume_source.py | 72 +- .../models/v1_azure_file_volume_source.py | 72 +- kubernetes/aio/client/models/v1_binding.py | 72 +- .../models/v1_bound_object_reference.py | 72 +- .../aio/client/models/v1_capabilities.py | 72 +- .../models/v1_capacity_request_policy.py | 72 +- .../v1_capacity_request_policy_range.py | 72 +- .../client/models/v1_capacity_requirements.py | 72 +- .../client/models/v1_cel_device_selector.py | 72 +- .../v1_ceph_fs_persistent_volume_source.py | 72 +- .../client/models/v1_ceph_fs_volume_source.py | 72 +- .../models/v1_certificate_signing_request.py | 72 +- ...1_certificate_signing_request_condition.py | 72 +- .../v1_certificate_signing_request_list.py | 72 +- .../v1_certificate_signing_request_spec.py | 72 +- .../v1_certificate_signing_request_status.py | 72 +- .../v1_cinder_persistent_volume_source.py | 72 +- .../client/models/v1_cinder_volume_source.py | 72 +- .../aio/client/models/v1_client_ip_config.py | 72 +- .../aio/client/models/v1_cluster_role.py | 72 +- .../client/models/v1_cluster_role_binding.py | 72 +- .../models/v1_cluster_role_binding_list.py | 72 +- .../aio/client/models/v1_cluster_role_list.py | 72 +- .../client/models/v1_cluster_trust_bundle.py | 72 +- .../models/v1_cluster_trust_bundle_list.py | 72 +- .../v1_cluster_trust_bundle_projection.py | 72 +- .../models/v1_cluster_trust_bundle_spec.py | 72 +- .../client/models/v1_component_condition.py | 72 +- .../aio/client/models/v1_component_status.py | 72 +- .../client/models/v1_component_status_list.py | 72 +- kubernetes/aio/client/models/v1_condition.py | 72 +- kubernetes/aio/client/models/v1_config_map.py | 72 +- .../client/models/v1_config_map_env_source.py | 72 +- .../models/v1_config_map_key_selector.py | 72 +- .../aio/client/models/v1_config_map_list.py | 72 +- .../v1_config_map_node_config_source.py | 72 +- .../client/models/v1_config_map_projection.py | 72 +- .../models/v1_config_map_volume_source.py | 72 +- kubernetes/aio/client/models/v1_container.py | 72 +- .../v1_container_extended_resource_request.py | 72 +- .../aio/client/models/v1_container_image.py | 72 +- .../aio/client/models/v1_container_port.py | 72 +- .../models/v1_container_resize_policy.py | 72 +- .../models/v1_container_restart_rule.py | 72 +- ...v1_container_restart_rule_on_exit_codes.py | 72 +- .../aio/client/models/v1_container_state.py | 72 +- .../models/v1_container_state_running.py | 72 +- .../models/v1_container_state_terminated.py | 72 +- .../models/v1_container_state_waiting.py | 72 +- .../aio/client/models/v1_container_status.py | 72 +- .../aio/client/models/v1_container_user.py | 72 +- .../client/models/v1_controller_revision.py | 72 +- .../models/v1_controller_revision_list.py | 72 +- kubernetes/aio/client/models/v1_counter.py | 72 +- .../aio/client/models/v1_counter_set.py | 72 +- kubernetes/aio/client/models/v1_cron_job.py | 72 +- .../aio/client/models/v1_cron_job_list.py | 72 +- .../aio/client/models/v1_cron_job_spec.py | 72 +- .../aio/client/models/v1_cron_job_status.py | 72 +- .../v1_cross_version_object_reference.py | 72 +- kubernetes/aio/client/models/v1_csi_driver.py | 72 +- .../aio/client/models/v1_csi_driver_list.py | 72 +- .../aio/client/models/v1_csi_driver_spec.py | 72 +- kubernetes/aio/client/models/v1_csi_node.py | 72 +- .../aio/client/models/v1_csi_node_driver.py | 72 +- .../aio/client/models/v1_csi_node_list.py | 72 +- .../aio/client/models/v1_csi_node_spec.py | 72 +- .../aio/client/models/v1_csi_node_status.py | 72 +- .../models/v1_csi_persistent_volume_source.py | 72 +- .../client/models/v1_csi_storage_capacity.py | 72 +- .../models/v1_csi_storage_capacity_list.py | 72 +- .../aio/client/models/v1_csi_volume_source.py | 72 +- .../v1_custom_resource_column_definition.py | 72 +- .../models/v1_custom_resource_conversion.py | 72 +- .../models/v1_custom_resource_definition.py | 72 +- ...v1_custom_resource_definition_condition.py | 72 +- .../v1_custom_resource_definition_list.py | 72 +- .../v1_custom_resource_definition_names.py | 72 +- .../v1_custom_resource_definition_spec.py | 72 +- .../v1_custom_resource_definition_status.py | 72 +- .../v1_custom_resource_definition_version.py | 72 +- .../v1_custom_resource_subresource_scale.py | 72 +- .../models/v1_custom_resource_subresources.py | 72 +- .../models/v1_custom_resource_validation.py | 72 +- .../aio/client/models/v1_daemon_endpoint.py | 72 +- kubernetes/aio/client/models/v1_daemon_set.py | 72 +- .../client/models/v1_daemon_set_condition.py | 72 +- .../aio/client/models/v1_daemon_set_list.py | 72 +- .../aio/client/models/v1_daemon_set_spec.py | 72 +- .../aio/client/models/v1_daemon_set_status.py | 72 +- .../models/v1_daemon_set_update_strategy.py | 72 +- .../aio/client/models/v1_delete_options.py | 72 +- kubernetes/aio/client/models/v1_deployment.py | 72 +- .../client/models/v1_deployment_condition.py | 72 +- .../aio/client/models/v1_deployment_list.py | 72 +- .../aio/client/models/v1_deployment_spec.py | 72 +- .../aio/client/models/v1_deployment_status.py | 72 +- .../client/models/v1_deployment_strategy.py | 72 +- kubernetes/aio/client/models/v1_device.py | 72 +- .../v1_device_allocation_configuration.py | 72 +- .../models/v1_device_allocation_result.py | 72 +- .../aio/client/models/v1_device_attribute.py | 72 +- .../aio/client/models/v1_device_capacity.py | 72 +- .../aio/client/models/v1_device_claim.py | 72 +- .../models/v1_device_claim_configuration.py | 72 +- .../aio/client/models/v1_device_class.py | 72 +- .../models/v1_device_class_configuration.py | 72 +- .../aio/client/models/v1_device_class_list.py | 72 +- .../aio/client/models/v1_device_class_spec.py | 72 +- .../aio/client/models/v1_device_constraint.py | 72 +- .../models/v1_device_counter_consumption.py | 72 +- .../models/v1_device_derived_attribute.py | 72 +- .../aio/client/models/v1_device_request.py | 72 +- .../v1_device_request_allocation_result.py | 72 +- .../aio/client/models/v1_device_selector.py | 72 +- .../client/models/v1_device_sub_request.py | 72 +- .../aio/client/models/v1_device_taint.py | 72 +- .../aio/client/models/v1_device_taint_rule.py | 72 +- .../models/v1_device_taint_rule_list.py | 72 +- .../models/v1_device_taint_rule_spec.py | 72 +- .../models/v1_device_taint_rule_status.py | 72 +- .../client/models/v1_device_taint_selector.py | 72 +- .../aio/client/models/v1_device_toleration.py | 72 +- .../models/v1_downward_api_projection.py | 72 +- .../models/v1_downward_api_volume_file.py | 72 +- .../models/v1_downward_api_volume_source.py | 72 +- .../models/v1_empty_dir_volume_source.py | 72 +- kubernetes/aio/client/models/v1_endpoint.py | 72 +- .../aio/client/models/v1_endpoint_address.py | 72 +- .../client/models/v1_endpoint_conditions.py | 72 +- .../aio/client/models/v1_endpoint_hints.py | 72 +- .../aio/client/models/v1_endpoint_slice.py | 72 +- .../client/models/v1_endpoint_slice_list.py | 72 +- .../aio/client/models/v1_endpoint_subset.py | 72 +- kubernetes/aio/client/models/v1_endpoints.py | 72 +- .../aio/client/models/v1_endpoints_list.py | 72 +- .../aio/client/models/v1_env_from_source.py | 72 +- kubernetes/aio/client/models/v1_env_var.py | 72 +- .../aio/client/models/v1_env_var_source.py | 72 +- .../client/models/v1_ephemeral_container.py | 72 +- .../models/v1_ephemeral_volume_source.py | 72 +- .../aio/client/models/v1_event_source.py | 72 +- kubernetes/aio/client/models/v1_eviction.py | 72 +- .../client/models/v1_eviction_responder.py | 72 +- .../client/models/v1_exact_device_request.py | 72 +- .../aio/client/models/v1_exec_action.py | 72 +- .../v1_exempt_priority_level_configuration.py | 72 +- .../client/models/v1_expression_warning.py | 72 +- .../models/v1_external_documentation.py | 72 +- .../aio/client/models/v1_fc_volume_source.py | 72 +- .../models/v1_field_selector_attributes.py | 72 +- .../models/v1_field_selector_requirement.py | 72 +- .../aio/client/models/v1_file_key_selector.py | 72 +- .../v1_flex_persistent_volume_source.py | 72 +- .../client/models/v1_flex_volume_source.py | 72 +- .../client/models/v1_flocker_volume_source.py | 72 +- .../models/v1_flow_distinguisher_method.py | 72 +- .../aio/client/models/v1_flow_schema.py | 72 +- .../client/models/v1_flow_schema_condition.py | 72 +- .../aio/client/models/v1_flow_schema_list.py | 72 +- .../aio/client/models/v1_flow_schema_spec.py | 72 +- .../client/models/v1_flow_schema_status.py | 72 +- kubernetes/aio/client/models/v1_for_node.py | 72 +- kubernetes/aio/client/models/v1_for_zone.py | 72 +- .../v1_gce_persistent_disk_volume_source.py | 72 +- .../models/v1_git_repo_volume_source.py | 72 +- .../v1_glusterfs_persistent_volume_source.py | 72 +- .../models/v1_glusterfs_volume_source.py | 72 +- .../aio/client/models/v1_group_resource.py | 72 +- .../aio/client/models/v1_group_subject.py | 72 +- .../models/v1_group_version_for_discovery.py | 72 +- .../client/models/v1_group_version_kind.py | 72 +- .../aio/client/models/v1_grpc_action.py | 72 +- .../models/v1_horizontal_pod_autoscaler.py | 72 +- .../v1_horizontal_pod_autoscaler_list.py | 72 +- .../v1_horizontal_pod_autoscaler_spec.py | 72 +- .../v1_horizontal_pod_autoscaler_status.py | 72 +- kubernetes/aio/client/models/v1_host_alias.py | 72 +- kubernetes/aio/client/models/v1_host_ip.py | 72 +- .../models/v1_host_path_volume_source.py | 72 +- .../aio/client/models/v1_http_get_action.py | 72 +- .../aio/client/models/v1_http_header.py | 72 +- .../aio/client/models/v1_http_ingress_path.py | 72 +- .../models/v1_http_ingress_rule_value.py | 72 +- .../client/models/v1_image_volume_source.py | 72 +- .../client/models/v1_image_volume_status.py | 72 +- kubernetes/aio/client/models/v1_ingress.py | 72 +- .../aio/client/models/v1_ingress_backend.py | 72 +- .../aio/client/models/v1_ingress_class.py | 72 +- .../client/models/v1_ingress_class_list.py | 72 +- .../v1_ingress_class_parameters_reference.py | 72 +- .../client/models/v1_ingress_class_spec.py | 72 +- .../aio/client/models/v1_ingress_list.py | 72 +- .../v1_ingress_load_balancer_ingress.py | 72 +- .../models/v1_ingress_load_balancer_status.py | 72 +- .../client/models/v1_ingress_port_status.py | 72 +- .../aio/client/models/v1_ingress_rule.py | 72 +- .../models/v1_ingress_service_backend.py | 72 +- .../aio/client/models/v1_ingress_spec.py | 72 +- .../aio/client/models/v1_ingress_status.py | 72 +- .../aio/client/models/v1_ingress_tls.py | 72 +- kubernetes/aio/client/models/v1_ip_address.py | 72 +- .../aio/client/models/v1_ip_address_list.py | 72 +- .../aio/client/models/v1_ip_address_spec.py | 72 +- kubernetes/aio/client/models/v1_ip_block.py | 72 +- .../v1_iscsi_persistent_volume_source.py | 72 +- .../client/models/v1_iscsi_volume_source.py | 72 +- kubernetes/aio/client/models/v1_job.py | 72 +- .../aio/client/models/v1_job_condition.py | 72 +- kubernetes/aio/client/models/v1_job_list.py | 72 +- .../models/v1_job_scheduling_configuration.py | 72 +- kubernetes/aio/client/models/v1_job_spec.py | 72 +- kubernetes/aio/client/models/v1_job_status.py | 72 +- .../aio/client/models/v1_job_template_spec.py | 72 +- kubernetes/aio/client/models/v1_json_patch.py | 72 +- .../aio/client/models/v1_json_schema_props.py | 72 +- .../aio/client/models/v1_key_to_path.py | 72 +- .../aio/client/models/v1_label_selector.py | 72 +- .../models/v1_label_selector_attributes.py | 72 +- .../models/v1_label_selector_requirement.py | 72 +- kubernetes/aio/client/models/v1_lease.py | 72 +- kubernetes/aio/client/models/v1_lease_list.py | 72 +- kubernetes/aio/client/models/v1_lease_spec.py | 72 +- kubernetes/aio/client/models/v1_lifecycle.py | 72 +- .../aio/client/models/v1_lifecycle_handler.py | 72 +- .../aio/client/models/v1_limit_range.py | 72 +- .../aio/client/models/v1_limit_range_item.py | 72 +- .../aio/client/models/v1_limit_range_list.py | 72 +- .../aio/client/models/v1_limit_range_spec.py | 72 +- .../aio/client/models/v1_limit_response.py | 72 +- ...v1_limited_priority_level_configuration.py | 72 +- .../client/models/v1_linux_container_user.py | 72 +- kubernetes/aio/client/models/v1_list_meta.py | 72 +- .../client/models/v1_load_balancer_ingress.py | 72 +- .../client/models/v1_load_balancer_status.py | 72 +- .../models/v1_local_object_reference.py | 72 +- .../models/v1_local_subject_access_review.py | 72 +- .../client/models/v1_local_volume_source.py | 72 +- .../client/models/v1_managed_fields_entry.py | 72 +- .../aio/client/models/v1_match_condition.py | 72 +- .../aio/client/models/v1_match_resources.py | 72 +- .../client/models/v1_modify_volume_status.py | 72 +- .../models/v1_mutating_admission_policy.py | 72 +- .../v1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- .../v1_mutating_admission_policy_list.py | 72 +- .../v1_mutating_admission_policy_spec.py | 72 +- .../aio/client/models/v1_mutating_webhook.py | 72 +- .../v1_mutating_webhook_configuration.py | 72 +- .../v1_mutating_webhook_configuration_list.py | 72 +- kubernetes/aio/client/models/v1_mutation.py | 72 +- .../models/v1_named_rule_with_operations.py | 72 +- kubernetes/aio/client/models/v1_namespace.py | 72 +- .../client/models/v1_namespace_condition.py | 72 +- .../aio/client/models/v1_namespace_list.py | 72 +- .../aio/client/models/v1_namespace_spec.py | 72 +- .../aio/client/models/v1_namespace_status.py | 72 +- .../client/models/v1_network_device_data.py | 72 +- .../aio/client/models/v1_network_policy.py | 72 +- .../models/v1_network_policy_egress_rule.py | 72 +- .../models/v1_network_policy_ingress_rule.py | 72 +- .../client/models/v1_network_policy_list.py | 72 +- .../client/models/v1_network_policy_peer.py | 72 +- .../client/models/v1_network_policy_port.py | 72 +- .../client/models/v1_network_policy_spec.py | 72 +- .../aio/client/models/v1_nfs_volume_source.py | 72 +- kubernetes/aio/client/models/v1_node.py | 72 +- .../aio/client/models/v1_node_address.py | 72 +- .../aio/client/models/v1_node_affinity.py | 72 +- .../v1_node_allocatable_mapped_resources.py | 72 +- .../models/v1_node_allocatable_mapping.py | 72 +- .../models/v1_node_allocatable_overhead.py | 72 +- .../v1_node_allocatable_overhead_resources.py | 72 +- .../models/v1_node_allocatable_resource.py | 72 +- ..._node_allocatable_resource_claim_status.py | 72 +- .../aio/client/models/v1_node_condition.py | 72 +- .../client/models/v1_node_config_source.py | 72 +- .../client/models/v1_node_config_status.py | 72 +- .../client/models/v1_node_daemon_endpoints.py | 72 +- .../aio/client/models/v1_node_features.py | 72 +- kubernetes/aio/client/models/v1_node_list.py | 72 +- .../models/v1_node_pod_preemption_policy.py | 72 +- .../client/models/v1_node_runtime_handler.py | 72 +- .../v1_node_runtime_handler_features.py | 72 +- .../aio/client/models/v1_node_selector.py | 72 +- .../models/v1_node_selector_requirement.py | 72 +- .../client/models/v1_node_selector_term.py | 72 +- kubernetes/aio/client/models/v1_node_spec.py | 72 +- .../aio/client/models/v1_node_status.py | 72 +- .../aio/client/models/v1_node_swap_status.py | 72 +- .../aio/client/models/v1_node_system_info.py | 72 +- .../models/v1_non_resource_attributes.py | 72 +- .../models/v1_non_resource_policy_rule.py | 72 +- .../aio/client/models/v1_non_resource_rule.py | 72 +- .../client/models/v1_object_field_selector.py | 72 +- .../aio/client/models/v1_object_meta.py | 72 +- .../aio/client/models/v1_object_reference.py | 72 +- .../models/v1_opaque_device_configuration.py | 72 +- kubernetes/aio/client/models/v1_overhead.py | 72 +- .../aio/client/models/v1_owner_reference.py | 72 +- kubernetes/aio/client/models/v1_param_kind.py | 72 +- kubernetes/aio/client/models/v1_param_ref.py | 72 +- .../aio/client/models/v1_parent_reference.py | 72 +- .../aio/client/models/v1_persistent_volume.py | 72 +- .../models/v1_persistent_volume_claim.py | 72 +- .../v1_persistent_volume_claim_condition.py | 72 +- .../models/v1_persistent_volume_claim_list.py | 72 +- .../models/v1_persistent_volume_claim_spec.py | 72 +- .../v1_persistent_volume_claim_status.py | 72 +- .../v1_persistent_volume_claim_template.py | 72 +- ...1_persistent_volume_claim_volume_source.py | 72 +- .../models/v1_persistent_volume_list.py | 72 +- .../models/v1_persistent_volume_spec.py | 72 +- .../models/v1_persistent_volume_status.py | 72 +- ...v1_photon_persistent_disk_volume_source.py | 72 +- kubernetes/aio/client/models/v1_pod.py | 72 +- .../aio/client/models/v1_pod_affinity.py | 72 +- .../aio/client/models/v1_pod_affinity_term.py | 72 +- .../aio/client/models/v1_pod_anti_affinity.py | 72 +- .../models/v1_pod_certificate_projection.py | 72 +- .../models/v1_pod_certificate_request.py | 72 +- .../models/v1_pod_certificate_request_list.py | 72 +- .../models/v1_pod_certificate_request_spec.py | 72 +- .../v1_pod_certificate_request_status.py | 72 +- .../aio/client/models/v1_pod_condition.py | 72 +- .../client/models/v1_pod_disruption_budget.py | 72 +- .../models/v1_pod_disruption_budget_list.py | 72 +- .../models/v1_pod_disruption_budget_spec.py | 72 +- .../models/v1_pod_disruption_budget_status.py | 72 +- .../aio/client/models/v1_pod_dns_config.py | 72 +- .../client/models/v1_pod_dns_config_option.py | 72 +- .../v1_pod_extended_resource_claim_status.py | 72 +- .../client/models/v1_pod_failure_policy.py | 72 +- ...ailure_policy_on_exit_codes_requirement.py | 72 +- ...ailure_policy_on_pod_conditions_pattern.py | 72 +- .../models/v1_pod_failure_policy_rule.py | 72 +- kubernetes/aio/client/models/v1_pod_ip.py | 72 +- kubernetes/aio/client/models/v1_pod_list.py | 72 +- kubernetes/aio/client/models/v1_pod_os.py | 72 +- .../client/models/v1_pod_readiness_gate.py | 72 +- .../client/models/v1_pod_resource_claim.py | 72 +- .../models/v1_pod_resource_claim_status.py | 72 +- .../client/models/v1_pod_scheduling_gate.py | 72 +- .../client/models/v1_pod_scheduling_group.py | 72 +- .../client/models/v1_pod_security_context.py | 72 +- kubernetes/aio/client/models/v1_pod_spec.py | 72 +- kubernetes/aio/client/models/v1_pod_status.py | 72 +- .../aio/client/models/v1_pod_template.py | 72 +- .../aio/client/models/v1_pod_template_list.py | 72 +- .../aio/client/models/v1_pod_template_spec.py | 72 +- .../aio/client/models/v1_pod_volume_health.py | 72 +- .../aio/client/models/v1_policy_rule.py | 72 +- .../models/v1_policy_rules_with_subjects.py | 72 +- .../aio/client/models/v1_port_status.py | 72 +- .../models/v1_portworx_volume_source.py | 72 +- .../aio/client/models/v1_preconditions.py | 72 +- .../models/v1_preferred_scheduling_term.py | 72 +- .../aio/client/models/v1_priority_class.py | 72 +- .../client/models/v1_priority_class_list.py | 72 +- .../models/v1_priority_level_configuration.py | 72 +- ..._priority_level_configuration_condition.py | 72 +- .../v1_priority_level_configuration_list.py | 72 +- ..._priority_level_configuration_reference.py | 72 +- .../v1_priority_level_configuration_spec.py | 72 +- .../v1_priority_level_configuration_status.py | 72 +- kubernetes/aio/client/models/v1_probe.py | 72 +- .../models/v1_projected_volume_source.py | 72 +- .../client/models/v1_queuing_configuration.py | 72 +- .../client/models/v1_quobyte_volume_source.py | 72 +- .../models/v1_rbd_persistent_volume_source.py | 72 +- .../aio/client/models/v1_rbd_volume_source.py | 72 +- .../aio/client/models/v1_replica_set.py | 72 +- .../client/models/v1_replica_set_condition.py | 72 +- .../aio/client/models/v1_replica_set_list.py | 72 +- .../aio/client/models/v1_replica_set_spec.py | 72 +- .../client/models/v1_replica_set_status.py | 72 +- .../models/v1_replication_controller.py | 72 +- .../v1_replication_controller_condition.py | 72 +- .../models/v1_replication_controller_list.py | 72 +- .../models/v1_replication_controller_spec.py | 72 +- .../v1_replication_controller_status.py | 72 +- .../client/models/v1_resource_attributes.py | 72 +- .../v1_resource_claim_consumer_reference.py | 72 +- .../client/models/v1_resource_claim_list.py | 72 +- .../client/models/v1_resource_claim_spec.py | 72 +- .../client/models/v1_resource_claim_status.py | 72 +- .../models/v1_resource_claim_template.py | 72 +- .../models/v1_resource_claim_template_list.py | 72 +- .../models/v1_resource_claim_template_spec.py | 72 +- .../models/v1_resource_field_selector.py | 72 +- .../aio/client/models/v1_resource_health.py | 72 +- .../client/models/v1_resource_policy_rule.py | 72 +- .../aio/client/models/v1_resource_pool.py | 72 +- .../aio/client/models/v1_resource_quota.py | 72 +- .../client/models/v1_resource_quota_list.py | 72 +- .../client/models/v1_resource_quota_spec.py | 72 +- .../client/models/v1_resource_quota_status.py | 72 +- .../client/models/v1_resource_requirements.py | 72 +- .../aio/client/models/v1_resource_rule.py | 72 +- .../aio/client/models/v1_resource_slice.py | 72 +- .../client/models/v1_resource_slice_list.py | 72 +- .../client/models/v1_resource_slice_spec.py | 72 +- .../aio/client/models/v1_resource_status.py | 72 +- kubernetes/aio/client/models/v1_role.py | 72 +- .../aio/client/models/v1_role_binding.py | 72 +- .../aio/client/models/v1_role_binding_list.py | 72 +- kubernetes/aio/client/models/v1_role_list.py | 72 +- kubernetes/aio/client/models/v1_role_ref.py | 72 +- .../models/v1_rolling_update_daemon_set.py | 72 +- .../models/v1_rolling_update_deployment.py | 72 +- ...v1_rolling_update_stateful_set_strategy.py | 72 +- .../client/models/v1_rule_with_operations.py | 72 +- .../aio/client/models/v1_runtime_class.py | 72 +- .../client/models/v1_runtime_class_list.py | 72 +- kubernetes/aio/client/models/v1_scale.py | 72 +- .../v1_scale_io_persistent_volume_source.py | 72 +- .../models/v1_scale_io_volume_source.py | 72 +- kubernetes/aio/client/models/v1_scale_spec.py | 72 +- .../aio/client/models/v1_scale_status.py | 72 +- kubernetes/aio/client/models/v1_scheduling.py | 72 +- .../aio/client/models/v1_scope_selector.py | 72 +- ...v1_scoped_resource_selector_requirement.py | 72 +- .../aio/client/models/v1_se_linux_options.py | 72 +- .../aio/client/models/v1_seccomp_profile.py | 72 +- kubernetes/aio/client/models/v1_secret.py | 72 +- .../aio/client/models/v1_secret_env_source.py | 72 +- .../client/models/v1_secret_key_selector.py | 72 +- .../aio/client/models/v1_secret_list.py | 72 +- .../aio/client/models/v1_secret_projection.py | 72 +- .../aio/client/models/v1_secret_reference.py | 72 +- .../client/models/v1_secret_volume_source.py | 72 +- .../aio/client/models/v1_security_context.py | 72 +- .../aio/client/models/v1_selectable_field.py | 72 +- .../models/v1_self_subject_access_review.py | 72 +- .../v1_self_subject_access_review_spec.py | 72 +- .../client/models/v1_self_subject_review.py | 72 +- .../models/v1_self_subject_review_status.py | 72 +- .../models/v1_self_subject_rules_review.py | 72 +- .../v1_self_subject_rules_review_spec.py | 72 +- .../v1_server_address_by_client_cidr.py | 72 +- kubernetes/aio/client/models/v1_service.py | 72 +- .../aio/client/models/v1_service_account.py | 72 +- .../client/models/v1_service_account_list.py | 72 +- .../models/v1_service_account_subject.py | 72 +- .../v1_service_account_token_projection.py | 72 +- .../client/models/v1_service_backend_port.py | 72 +- .../aio/client/models/v1_service_cidr.py | 72 +- .../aio/client/models/v1_service_cidr_list.py | 72 +- .../aio/client/models/v1_service_cidr_spec.py | 72 +- .../client/models/v1_service_cidr_status.py | 72 +- .../aio/client/models/v1_service_list.py | 72 +- .../aio/client/models/v1_service_port.py | 72 +- .../aio/client/models/v1_service_spec.py | 72 +- .../aio/client/models/v1_service_status.py | 72 +- .../models/v1_session_affinity_config.py | 72 +- kubernetes/aio/client/models/v1_shard_info.py | 72 +- .../aio/client/models/v1_sleep_action.py | 72 +- .../aio/client/models/v1_stateful_set.py | 72 +- .../models/v1_stateful_set_condition.py | 72 +- .../aio/client/models/v1_stateful_set_list.py | 72 +- .../client/models/v1_stateful_set_ordinals.py | 72 +- ...ersistent_volume_claim_retention_policy.py | 72 +- .../aio/client/models/v1_stateful_set_spec.py | 72 +- .../client/models/v1_stateful_set_status.py | 72 +- .../models/v1_stateful_set_update_strategy.py | 72 +- kubernetes/aio/client/models/v1_status.py | 72 +- .../aio/client/models/v1_status_cause.py | 72 +- .../aio/client/models/v1_status_details.py | 72 +- .../aio/client/models/v1_storage_class.py | 72 +- .../client/models/v1_storage_class_list.py | 72 +- .../aio/client/models/v1_storage_health.py | 72 +- .../models/v1_storage_health_condition.py | 72 +- .../v1_storage_os_persistent_volume_source.py | 72 +- .../models/v1_storage_os_volume_source.py | 72 +- .../models/v1_storage_version_migration.py | 72 +- .../v1_storage_version_migration_list.py | 72 +- .../v1_storage_version_migration_spec.py | 72 +- .../v1_storage_version_migration_status.py | 72 +- .../client/models/v1_subject_access_review.py | 72 +- .../models/v1_subject_access_review_spec.py | 72 +- .../models/v1_subject_access_review_status.py | 72 +- .../models/v1_subject_rules_review_status.py | 72 +- .../aio/client/models/v1_success_policy.py | 72 +- .../client/models/v1_success_policy_rule.py | 72 +- kubernetes/aio/client/models/v1_sysctl.py | 72 +- kubernetes/aio/client/models/v1_taint.py | 72 +- .../aio/client/models/v1_tcp_socket_action.py | 72 +- .../client/models/v1_token_request_spec.py | 72 +- .../client/models/v1_token_request_status.py | 72 +- .../aio/client/models/v1_token_review.py | 72 +- .../aio/client/models/v1_token_review_spec.py | 72 +- .../client/models/v1_token_review_status.py | 72 +- kubernetes/aio/client/models/v1_toleration.py | 72 +- .../v1_topology_selector_label_requirement.py | 72 +- .../models/v1_topology_selector_term.py | 72 +- .../models/v1_topology_spread_constraint.py | 72 +- .../aio/client/models/v1_type_checking.py | 72 +- .../models/v1_typed_local_object_reference.py | 72 +- .../models/v1_typed_object_reference.py | 72 +- .../models/v1_uncounted_terminated_pods.py | 72 +- kubernetes/aio/client/models/v1_user_info.py | 72 +- .../aio/client/models/v1_user_subject.py | 72 +- .../models/v1_validating_admission_policy.py | 72 +- .../v1_validating_admission_policy_binding.py | 72 +- ...alidating_admission_policy_binding_list.py | 72 +- ...alidating_admission_policy_binding_spec.py | 72 +- .../v1_validating_admission_policy_list.py | 72 +- .../v1_validating_admission_policy_spec.py | 72 +- .../v1_validating_admission_policy_status.py | 72 +- .../client/models/v1_validating_webhook.py | 72 +- .../v1_validating_webhook_configuration.py | 72 +- ...1_validating_webhook_configuration_list.py | 72 +- kubernetes/aio/client/models/v1_validation.py | 72 +- .../aio/client/models/v1_validation_rule.py | 72 +- kubernetes/aio/client/models/v1_variable.py | 72 +- kubernetes/aio/client/models/v1_volume.py | 72 +- .../aio/client/models/v1_volume_attachment.py | 72 +- .../models/v1_volume_attachment_list.py | 72 +- .../models/v1_volume_attachment_source.py | 72 +- .../models/v1_volume_attachment_spec.py | 72 +- .../models/v1_volume_attachment_status.py | 72 +- .../models/v1_volume_attributes_class.py | 72 +- .../models/v1_volume_attributes_class_list.py | 72 +- .../aio/client/models/v1_volume_device.py | 72 +- .../aio/client/models/v1_volume_error.py | 72 +- .../models/v1_volume_health_condition.py | 72 +- .../client/models/v1_volume_health_status.py | 72 +- .../aio/client/models/v1_volume_mount.py | 72 +- .../client/models/v1_volume_mount_status.py | 72 +- .../client/models/v1_volume_node_affinity.py | 72 +- .../client/models/v1_volume_node_resources.py | 72 +- .../aio/client/models/v1_volume_projection.py | 72 +- .../models/v1_volume_resource_requirements.py | 72 +- .../aio/client/models/v1_volume_status.py | 72 +- .../v1_vsphere_virtual_disk_volume_source.py | 72 +- .../aio/client/models/v1_watch_event.py | 72 +- .../client/models/v1_webhook_conversion.py | 72 +- .../models/v1_weighted_pod_affinity_term.py | 72 +- .../v1_windows_security_context_options.py | 72 +- .../models/v1alpha1_apply_configuration.py | 72 +- .../aio/client/models/v1alpha1_eviction.py | 72 +- .../client/models/v1alpha1_eviction_list.py | 72 +- .../models/v1alpha1_eviction_pod_reference.py | 72 +- .../models/v1alpha1_eviction_request.py | 72 +- .../models/v1alpha1_eviction_request_list.py | 72 +- ...v1alpha1_eviction_request_pod_reference.py | 72 +- .../models/v1alpha1_eviction_request_spec.py | 72 +- .../v1alpha1_eviction_request_status.py | 72 +- .../v1alpha1_eviction_request_target.py | 72 +- .../client/models/v1alpha1_eviction_spec.py | 72 +- .../client/models/v1alpha1_eviction_status.py | 72 +- .../client/models/v1alpha1_eviction_target.py | 72 +- .../aio/client/models/v1alpha1_json_patch.py | 72 +- .../client/models/v1alpha1_match_condition.py | 72 +- .../client/models/v1alpha1_match_resources.py | 72 +- .../v1alpha1_mutating_admission_policy.py | 72 +- ...lpha1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- ...v1alpha1_mutating_admission_policy_list.py | 72 +- ...v1alpha1_mutating_admission_policy_spec.py | 72 +- .../aio/client/models/v1alpha1_mutation.py | 72 +- .../v1alpha1_named_rule_with_operations.py | 72 +- .../aio/client/models/v1alpha1_param_kind.py | 72 +- .../aio/client/models/v1alpha1_param_ref.py | 72 +- .../aio/client/models/v1alpha1_requester.py | 72 +- .../models/v1alpha1_responder_status.py | 72 +- .../models/v1alpha1_server_storage_version.py | 72 +- .../client/models/v1alpha1_storage_version.py | 72 +- .../v1alpha1_storage_version_condition.py | 72 +- .../models/v1alpha1_storage_version_list.py | 72 +- .../models/v1alpha1_storage_version_status.py | 72 +- .../models/v1alpha1_target_responder.py | 72 +- .../aio/client/models/v1alpha1_variable.py | 72 +- .../client/models/v1alpha2_lease_candidate.py | 72 +- .../models/v1alpha2_lease_candidate_list.py | 72 +- .../models/v1alpha2_lease_candidate_spec.py | 72 +- .../v1alpha3_composite_disruption_mode.py | 72 +- ...alpha3_composite_gang_scheduling_policy.py | 72 +- .../models/v1alpha3_composite_pod_group.py | 72 +- .../v1alpha3_composite_pod_group_list.py | 72 +- ...posite_pod_group_scheduling_constraints.py | 72 +- ...3_composite_pod_group_scheduling_policy.py | 72 +- .../v1alpha3_composite_pod_group_spec.py | 72 +- .../v1alpha3_composite_pod_group_status.py | 72 +- .../v1alpha3_composite_pod_group_template.py | 72 +- .../client/models/v1alpha3_device_taint.py | 72 +- .../models/v1alpha3_device_taint_rule.py | 72 +- .../models/v1alpha3_device_taint_rule_list.py | 72 +- .../models/v1alpha3_device_taint_rule_spec.py | 72 +- .../v1alpha3_device_taint_rule_status.py | 72 +- .../models/v1alpha3_device_taint_selector.py | 72 +- .../client/models/v1alpha3_disruption_mode.py | 72 +- .../models/v1alpha3_gang_scheduling_policy.py | 72 +- .../models/v1alpha3_partition_type_status.py | 72 +- .../aio/client/models/v1alpha3_pod_group.py | 72 +- .../client/models/v1alpha3_pod_group_list.py | 72 +- .../v1alpha3_pod_group_resource_claim.py | 72 +- ...1alpha3_pod_group_resource_claim_status.py | 72 +- ...alpha3_pod_group_scheduling_constraints.py | 72 +- .../v1alpha3_pod_group_scheduling_policy.py | 72 +- .../client/models/v1alpha3_pod_group_spec.py | 72 +- .../models/v1alpha3_pod_group_status.py | 72 +- .../models/v1alpha3_pod_group_template.py | 72 +- .../aio/client/models/v1alpha3_pool_status.py | 72 +- .../v1alpha3_resource_pool_status_request.py | 72 +- ...lpha3_resource_pool_status_request_list.py | 72 +- ...lpha3_resource_pool_status_request_spec.py | 72 +- ...ha3_resource_pool_status_request_status.py | 72 +- .../v1alpha3_shareable_capacity_status.py | 72 +- .../v1alpha3_shareable_summary_status.py | 72 +- .../models/v1alpha3_topology_constraint.py | 72 +- .../v1alpha3_typed_local_object_reference.py | 72 +- .../aio/client/models/v1alpha3_workload.py | 72 +- .../client/models/v1alpha3_workload_list.py | 72 +- ...pha3_workload_pod_group_disruption_mode.py | 72 +- ...rkload_pod_group_gang_scheduling_policy.py | 72 +- ...lpha3_workload_pod_group_resource_claim.py | 72 +- ...rkload_pod_group_scheduling_constraints.py | 72 +- ...a3_workload_pod_group_scheduling_policy.py | 72 +- .../models/v1alpha3_workload_reference.py | 72 +- .../client/models/v1alpha3_workload_spec.py | 72 +- .../models/v1beta1_allocated_device_status.py | 72 +- .../models/v1beta1_allocation_result.py | 72 +- .../models/v1beta1_apply_configuration.py | 72 +- .../aio/client/models/v1beta1_basic_device.py | 72 +- .../models/v1beta1_capacity_request_policy.py | 72 +- .../v1beta1_capacity_request_policy_range.py | 72 +- .../models/v1beta1_capacity_requirements.py | 72 +- .../models/v1beta1_cel_device_selector.py | 72 +- .../models/v1beta1_cluster_trust_bundle.py | 72 +- .../v1beta1_cluster_trust_bundle_list.py | 72 +- .../v1beta1_cluster_trust_bundle_spec.py | 72 +- .../v1beta1_composite_disruption_mode.py | 72 +- ...1beta1_composite_gang_scheduling_policy.py | 72 +- ...posite_pod_group_scheduling_constraints.py | 72 +- ...1_composite_pod_group_scheduling_policy.py | 72 +- .../v1beta1_composite_pod_group_template.py | 72 +- .../aio/client/models/v1beta1_counter.py | 72 +- .../aio/client/models/v1beta1_counter_set.py | 72 +- .../aio/client/models/v1beta1_device.py | 72 +- ...v1beta1_device_allocation_configuration.py | 72 +- .../v1beta1_device_allocation_result.py | 72 +- .../client/models/v1beta1_device_attribute.py | 72 +- .../client/models/v1beta1_device_capacity.py | 72 +- .../aio/client/models/v1beta1_device_claim.py | 72 +- .../v1beta1_device_claim_configuration.py | 72 +- .../aio/client/models/v1beta1_device_class.py | 72 +- .../v1beta1_device_class_configuration.py | 72 +- .../models/v1beta1_device_class_list.py | 72 +- .../models/v1beta1_device_class_spec.py | 72 +- .../models/v1beta1_device_constraint.py | 72 +- .../v1beta1_device_counter_consumption.py | 72 +- .../v1beta1_device_derived_attribute.py | 72 +- .../client/models/v1beta1_device_request.py | 72 +- ...1beta1_device_request_allocation_result.py | 72 +- .../client/models/v1beta1_device_selector.py | 72 +- .../models/v1beta1_device_sub_request.py | 72 +- .../aio/client/models/v1beta1_device_taint.py | 72 +- .../models/v1beta1_device_toleration.py | 72 +- .../client/models/v1beta1_disruption_mode.py | 72 +- .../models/v1beta1_gang_scheduling_policy.py | 72 +- .../aio/client/models/v1beta1_json_patch.py | 72 +- .../client/models/v1beta1_lease_candidate.py | 72 +- .../models/v1beta1_lease_candidate_list.py | 72 +- .../models/v1beta1_lease_candidate_spec.py | 72 +- .../client/models/v1beta1_match_condition.py | 72 +- .../client/models/v1beta1_match_resources.py | 72 +- .../v1beta1_mutating_admission_policy.py | 72 +- ...beta1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- .../v1beta1_mutating_admission_policy_list.py | 72 +- .../v1beta1_mutating_admission_policy_spec.py | 72 +- .../aio/client/models/v1beta1_mutation.py | 72 +- .../v1beta1_named_rule_with_operations.py | 72 +- .../models/v1beta1_network_device_data.py | 72 +- .../v1beta1_node_allocatable_mapping.py | 72 +- .../v1beta1_node_allocatable_overhead.py | 72 +- .../v1beta1_node_allocatable_resource.py | 72 +- .../v1beta1_opaque_device_configuration.py | 72 +- .../aio/client/models/v1beta1_param_kind.py | 72 +- .../aio/client/models/v1beta1_param_ref.py | 72 +- .../models/v1beta1_pod_certificate_request.py | 72 +- .../v1beta1_pod_certificate_request_list.py | 72 +- .../v1beta1_pod_certificate_request_spec.py | 72 +- .../v1beta1_pod_certificate_request_status.py | 72 +- .../aio/client/models/v1beta1_pod_group.py | 72 +- .../client/models/v1beta1_pod_group_list.py | 72 +- .../v1beta1_pod_group_resource_claim.py | 72 +- ...v1beta1_pod_group_resource_claim_status.py | 72 +- ...1beta1_pod_group_scheduling_constraints.py | 72 +- .../v1beta1_pod_group_scheduling_policy.py | 72 +- .../client/models/v1beta1_pod_group_spec.py | 72 +- .../client/models/v1beta1_pod_group_status.py | 72 +- .../models/v1beta1_pod_group_template.py | 72 +- .../client/models/v1beta1_resource_claim.py | 72 +- ...beta1_resource_claim_consumer_reference.py | 72 +- .../models/v1beta1_resource_claim_list.py | 72 +- .../models/v1beta1_resource_claim_spec.py | 72 +- .../models/v1beta1_resource_claim_status.py | 72 +- .../models/v1beta1_resource_claim_template.py | 72 +- .../v1beta1_resource_claim_template_list.py | 72 +- .../v1beta1_resource_claim_template_spec.py | 72 +- .../client/models/v1beta1_resource_pool.py | 72 +- .../client/models/v1beta1_resource_slice.py | 72 +- .../models/v1beta1_resource_slice_list.py | 72 +- .../models/v1beta1_resource_slice_spec.py | 72 +- .../v1beta1_storage_version_migration.py | 72 +- .../v1beta1_storage_version_migration_list.py | 72 +- .../v1beta1_storage_version_migration_spec.py | 72 +- ...1beta1_storage_version_migration_status.py | 72 +- .../models/v1beta1_topology_constraint.py | 72 +- .../v1beta1_typed_local_object_reference.py | 72 +- .../aio/client/models/v1beta1_variable.py | 72 +- .../aio/client/models/v1beta1_workload.py | 72 +- .../client/models/v1beta1_workload_list.py | 72 +- .../models/v1beta1_workload_reference.py | 72 +- .../client/models/v1beta1_workload_spec.py | 72 +- .../models/v1beta2_allocated_device_status.py | 72 +- .../models/v1beta2_allocation_result.py | 72 +- .../models/v1beta2_capacity_request_policy.py | 72 +- .../v1beta2_capacity_request_policy_range.py | 72 +- .../models/v1beta2_capacity_requirements.py | 72 +- .../models/v1beta2_cel_device_selector.py | 72 +- .../aio/client/models/v1beta2_counter.py | 72 +- .../aio/client/models/v1beta2_counter_set.py | 72 +- .../aio/client/models/v1beta2_device.py | 72 +- ...v1beta2_device_allocation_configuration.py | 72 +- .../v1beta2_device_allocation_result.py | 72 +- .../client/models/v1beta2_device_attribute.py | 72 +- .../client/models/v1beta2_device_capacity.py | 72 +- .../aio/client/models/v1beta2_device_claim.py | 72 +- .../v1beta2_device_claim_configuration.py | 72 +- .../aio/client/models/v1beta2_device_class.py | 72 +- .../v1beta2_device_class_configuration.py | 72 +- .../models/v1beta2_device_class_list.py | 72 +- .../models/v1beta2_device_class_spec.py | 72 +- .../models/v1beta2_device_constraint.py | 72 +- .../v1beta2_device_counter_consumption.py | 72 +- .../v1beta2_device_derived_attribute.py | 72 +- .../client/models/v1beta2_device_request.py | 72 +- ...1beta2_device_request_allocation_result.py | 72 +- .../client/models/v1beta2_device_selector.py | 72 +- .../models/v1beta2_device_sub_request.py | 72 +- .../aio/client/models/v1beta2_device_taint.py | 72 +- .../models/v1beta2_device_taint_rule.py | 72 +- .../models/v1beta2_device_taint_rule_list.py | 72 +- .../models/v1beta2_device_taint_rule_spec.py | 72 +- .../v1beta2_device_taint_rule_status.py | 72 +- .../models/v1beta2_device_taint_selector.py | 72 +- .../models/v1beta2_device_toleration.py | 72 +- .../models/v1beta2_exact_device_request.py | 72 +- .../models/v1beta2_network_device_data.py | 72 +- .../v1beta2_node_allocatable_mapping.py | 72 +- .../v1beta2_node_allocatable_overhead.py | 72 +- .../v1beta2_node_allocatable_resource.py | 72 +- .../v1beta2_opaque_device_configuration.py | 72 +- .../client/models/v1beta2_resource_claim.py | 72 +- ...beta2_resource_claim_consumer_reference.py | 72 +- .../models/v1beta2_resource_claim_list.py | 72 +- .../models/v1beta2_resource_claim_spec.py | 72 +- .../models/v1beta2_resource_claim_status.py | 72 +- .../models/v1beta2_resource_claim_template.py | 72 +- .../v1beta2_resource_claim_template_list.py | 72 +- .../v1beta2_resource_claim_template_spec.py | 72 +- .../client/models/v1beta2_resource_pool.py | 72 +- .../client/models/v1beta2_resource_slice.py | 72 +- .../models/v1beta2_resource_slice_list.py | 72 +- .../models/v1beta2_resource_slice_spec.py | 72 +- .../client/models/v2_api_group_discovery.py | 72 +- .../models/v2_api_group_discovery_list.py | 72 +- .../models/v2_api_resource_discovery.py | 72 +- .../models/v2_api_subresource_discovery.py | 72 +- .../client/models/v2_api_version_discovery.py | 72 +- .../v2_container_resource_metric_source.py | 72 +- .../v2_container_resource_metric_status.py | 72 +- .../v2_cross_version_object_reference.py | 72 +- .../models/v2_external_metric_source.py | 72 +- .../models/v2_external_metric_status.py | 72 +- .../models/v2_horizontal_pod_autoscaler.py | 72 +- .../v2_horizontal_pod_autoscaler_behavior.py | 72 +- .../v2_horizontal_pod_autoscaler_condition.py | 72 +- .../v2_horizontal_pod_autoscaler_list.py | 72 +- .../v2_horizontal_pod_autoscaler_spec.py | 72 +- .../v2_horizontal_pod_autoscaler_status.py | 72 +- .../client/models/v2_hpa_scaling_policy.py | 72 +- .../aio/client/models/v2_hpa_scaling_rules.py | 72 +- .../aio/client/models/v2_metric_identifier.py | 72 +- .../aio/client/models/v2_metric_spec.py | 72 +- .../aio/client/models/v2_metric_status.py | 72 +- .../aio/client/models/v2_metric_target.py | 72 +- .../client/models/v2_metric_value_status.py | 72 +- .../client/models/v2_object_metric_source.py | 72 +- .../client/models/v2_object_metric_status.py | 72 +- .../client/models/v2_pods_metric_source.py | 72 +- .../client/models/v2_pods_metric_status.py | 72 +- .../models/v2_resource_metric_source.py | 72 +- .../models/v2_resource_metric_status.py | 72 +- .../models/v2beta1_api_group_discovery.py | 72 +- .../v2beta1_api_group_discovery_list.py | 72 +- .../models/v2beta1_api_resource_discovery.py | 72 +- .../v2beta1_api_subresource_discovery.py | 72 +- .../models/v2beta1_api_version_discovery.py | 72 +- kubernetes/aio/client/models/version_info.py | 72 +- kubernetes/aio/client/rest.py | 3 +- kubernetes/client/_legacy_model_helpers.py | 80 ++ .../client/api/admissionregistration_api.py | 4 +- .../api/admissionregistration_v1_api.py | 212 ++-- .../api/admissionregistration_v1alpha1_api.py | 68 +- .../api/admissionregistration_v1beta1_api.py | 68 +- kubernetes/client/api/apiextensions_api.py | 4 +- kubernetes/client/api/apiextensions_v1_api.py | 52 +- kubernetes/client/api/apiregistration_api.py | 4 +- .../client/api/apiregistration_v1_api.py | 52 +- kubernetes/client/api/apis_api.py | 4 +- kubernetes/client/api/apps_api.py | 4 +- kubernetes/client/api/apps_v1_api.py | 296 +++--- kubernetes/client/api/authentication_api.py | 4 +- .../client/api/authentication_v1_api.py | 12 +- kubernetes/client/api/authorization_api.py | 4 +- kubernetes/client/api/authorization_v1_api.py | 20 +- kubernetes/client/api/autoscaling_api.py | 4 +- kubernetes/client/api/autoscaling_v1_api.py | 56 +- kubernetes/client/api/autoscaling_v2_api.py | 56 +- kubernetes/client/api/batch_api.py | 4 +- kubernetes/client/api/batch_v1_api.py | 108 +- kubernetes/client/api/certificates_api.py | 4 +- kubernetes/client/api/certificates_v1_api.py | 152 +-- .../client/api/certificates_v1beta1_api.py | 88 +- kubernetes/client/api/coordination_api.py | 4 +- kubernetes/client/api/coordination_v1_api.py | 40 +- .../client/api/coordination_v1alpha2_api.py | 40 +- .../client/api/coordination_v1beta1_api.py | 40 +- kubernetes/client/api/core_api.py | 4 +- kubernetes/client/api/core_v1_api.py | 928 +++++++++--------- kubernetes/client/api/custom_objects_api.py | 136 +-- kubernetes/client/api/discovery_api.py | 4 +- kubernetes/client/api/discovery_v1_api.py | 40 +- kubernetes/client/api/events_api.py | 4 +- kubernetes/client/api/events_v1_api.py | 40 +- .../client/api/flowcontrol_apiserver_api.py | 4 +- .../api/flowcontrol_apiserver_v1_api.py | 100 +- .../client/api/internal_apiserver_api.py | 4 +- .../api/internal_apiserver_v1alpha1_api.py | 52 +- kubernetes/client/api/lifecycle_api.py | 4 +- .../client/api/lifecycle_v1alpha1_api.py | 108 +- kubernetes/client/api/logs_api.py | 4 +- kubernetes/client/api/networking_api.py | 4 +- kubernetes/client/api/networking_v1_api.py | 204 ++-- kubernetes/client/api/node_api.py | 4 +- kubernetes/client/api/node_v1_api.py | 36 +- kubernetes/client/api/openid_api.py | 4 +- kubernetes/client/api/policy_api.py | 4 +- kubernetes/client/api/policy_v1_api.py | 56 +- .../client/api/rbac_authorization_api.py | 4 +- .../client/api/rbac_authorization_v1_api.py | 140 +-- kubernetes/client/api/resource_api.py | 4 +- kubernetes/client/api/resource_v1_api.py | 204 ++-- .../client/api/resource_v1alpha3_api.py | 100 +- kubernetes/client/api/resource_v1beta1_api.py | 156 +-- kubernetes/client/api/resource_v1beta2_api.py | 204 ++-- kubernetes/client/api/scheduling_api.py | 4 +- kubernetes/client/api/scheduling_v1_api.py | 36 +- .../client/api/scheduling_v1alpha3_api.py | 144 +-- .../client/api/scheduling_v1beta1_api.py | 92 +- kubernetes/client/api/storage_api.py | 4 +- kubernetes/client/api/storage_v1_api.py | 232 ++--- kubernetes/client/api/storagemigration_api.py | 4 +- .../client/api/storagemigration_v1_api.py | 52 +- .../api/storagemigration_v1beta1_api.py | 52 +- kubernetes/client/api/version_api.py | 4 +- kubernetes/client/api/well_known_api.py | 4 +- kubernetes/client/api_client.py | 87 +- ...issionregistration_v1_service_reference.py | 72 +- ...onregistration_v1_webhook_client_config.py | 72 +- .../apiextensions_v1_service_reference.py | 72 +- .../apiextensions_v1_webhook_client_config.py | 72 +- .../apiregistration_v1_service_reference.py | 72 +- .../models/authentication_v1_token_request.py | 72 +- .../client/models/core_v1_endpoint_port.py | 72 +- kubernetes/client/models/core_v1_event.py | 72 +- .../client/models/core_v1_event_list.py | 72 +- .../client/models/core_v1_event_series.py | 72 +- .../client/models/core_v1_resource_claim.py | 72 +- .../models/discovery_v1_endpoint_port.py | 72 +- kubernetes/client/models/events_v1_event.py | 72 +- .../client/models/events_v1_event_list.py | 72 +- .../client/models/events_v1_event_series.py | 72 +- .../client/models/flowcontrol_v1_subject.py | 72 +- kubernetes/client/models/rbac_v1_subject.py | 72 +- .../models/resource_v1_resource_claim.py | 72 +- .../client/models/storage_v1_token_request.py | 72 +- kubernetes/client/models/v1_affinity.py | 72 +- .../client/models/v1_aggregation_rule.py | 72 +- .../models/v1_allocated_device_status.py | 72 +- .../client/models/v1_allocation_result.py | 72 +- kubernetes/client/models/v1_api_group.py | 72 +- kubernetes/client/models/v1_api_group_list.py | 72 +- kubernetes/client/models/v1_api_resource.py | 72 +- .../client/models/v1_api_resource_list.py | 72 +- kubernetes/client/models/v1_api_service.py | 72 +- .../client/models/v1_api_service_condition.py | 72 +- .../client/models/v1_api_service_list.py | 72 +- .../client/models/v1_api_service_spec.py | 72 +- .../client/models/v1_api_service_status.py | 72 +- kubernetes/client/models/v1_api_versions.py | 72 +- .../client/models/v1_app_armor_profile.py | 72 +- .../client/models/v1_apply_configuration.py | 72 +- .../client/models/v1_attached_volume.py | 72 +- .../client/models/v1_audit_annotation.py | 72 +- ...1_aws_elastic_block_store_volume_source.py | 72 +- .../models/v1_azure_disk_volume_source.py | 72 +- .../v1_azure_file_persistent_volume_source.py | 72 +- .../models/v1_azure_file_volume_source.py | 72 +- kubernetes/client/models/v1_binding.py | 72 +- .../models/v1_bound_object_reference.py | 72 +- kubernetes/client/models/v1_capabilities.py | 72 +- .../models/v1_capacity_request_policy.py | 72 +- .../v1_capacity_request_policy_range.py | 72 +- .../client/models/v1_capacity_requirements.py | 72 +- .../client/models/v1_cel_device_selector.py | 72 +- .../v1_ceph_fs_persistent_volume_source.py | 72 +- .../client/models/v1_ceph_fs_volume_source.py | 72 +- .../models/v1_certificate_signing_request.py | 72 +- ...1_certificate_signing_request_condition.py | 72 +- .../v1_certificate_signing_request_list.py | 72 +- .../v1_certificate_signing_request_spec.py | 72 +- .../v1_certificate_signing_request_status.py | 72 +- .../v1_cinder_persistent_volume_source.py | 72 +- .../client/models/v1_cinder_volume_source.py | 72 +- .../client/models/v1_client_ip_config.py | 72 +- kubernetes/client/models/v1_cluster_role.py | 72 +- .../client/models/v1_cluster_role_binding.py | 72 +- .../models/v1_cluster_role_binding_list.py | 72 +- .../client/models/v1_cluster_role_list.py | 72 +- .../client/models/v1_cluster_trust_bundle.py | 72 +- .../models/v1_cluster_trust_bundle_list.py | 72 +- .../v1_cluster_trust_bundle_projection.py | 72 +- .../models/v1_cluster_trust_bundle_spec.py | 72 +- .../client/models/v1_component_condition.py | 72 +- .../client/models/v1_component_status.py | 72 +- .../client/models/v1_component_status_list.py | 72 +- kubernetes/client/models/v1_condition.py | 72 +- kubernetes/client/models/v1_config_map.py | 72 +- .../client/models/v1_config_map_env_source.py | 72 +- .../models/v1_config_map_key_selector.py | 72 +- .../client/models/v1_config_map_list.py | 72 +- .../v1_config_map_node_config_source.py | 72 +- .../client/models/v1_config_map_projection.py | 72 +- .../models/v1_config_map_volume_source.py | 72 +- kubernetes/client/models/v1_container.py | 72 +- .../v1_container_extended_resource_request.py | 72 +- .../client/models/v1_container_image.py | 72 +- kubernetes/client/models/v1_container_port.py | 72 +- .../models/v1_container_resize_policy.py | 72 +- .../models/v1_container_restart_rule.py | 72 +- ...v1_container_restart_rule_on_exit_codes.py | 72 +- .../client/models/v1_container_state.py | 72 +- .../models/v1_container_state_running.py | 72 +- .../models/v1_container_state_terminated.py | 72 +- .../models/v1_container_state_waiting.py | 72 +- .../client/models/v1_container_status.py | 72 +- kubernetes/client/models/v1_container_user.py | 72 +- .../client/models/v1_controller_revision.py | 72 +- .../models/v1_controller_revision_list.py | 72 +- kubernetes/client/models/v1_counter.py | 72 +- kubernetes/client/models/v1_counter_set.py | 72 +- kubernetes/client/models/v1_cron_job.py | 72 +- kubernetes/client/models/v1_cron_job_list.py | 72 +- kubernetes/client/models/v1_cron_job_spec.py | 72 +- .../client/models/v1_cron_job_status.py | 72 +- .../v1_cross_version_object_reference.py | 72 +- kubernetes/client/models/v1_csi_driver.py | 72 +- .../client/models/v1_csi_driver_list.py | 72 +- .../client/models/v1_csi_driver_spec.py | 72 +- kubernetes/client/models/v1_csi_node.py | 72 +- .../client/models/v1_csi_node_driver.py | 72 +- kubernetes/client/models/v1_csi_node_list.py | 72 +- kubernetes/client/models/v1_csi_node_spec.py | 72 +- .../client/models/v1_csi_node_status.py | 72 +- .../models/v1_csi_persistent_volume_source.py | 72 +- .../client/models/v1_csi_storage_capacity.py | 72 +- .../models/v1_csi_storage_capacity_list.py | 72 +- .../client/models/v1_csi_volume_source.py | 72 +- .../v1_custom_resource_column_definition.py | 72 +- .../models/v1_custom_resource_conversion.py | 72 +- .../models/v1_custom_resource_definition.py | 72 +- ...v1_custom_resource_definition_condition.py | 72 +- .../v1_custom_resource_definition_list.py | 72 +- .../v1_custom_resource_definition_names.py | 72 +- .../v1_custom_resource_definition_spec.py | 72 +- .../v1_custom_resource_definition_status.py | 72 +- .../v1_custom_resource_definition_version.py | 72 +- .../v1_custom_resource_subresource_scale.py | 72 +- .../models/v1_custom_resource_subresources.py | 72 +- .../models/v1_custom_resource_validation.py | 72 +- .../client/models/v1_daemon_endpoint.py | 72 +- kubernetes/client/models/v1_daemon_set.py | 72 +- .../client/models/v1_daemon_set_condition.py | 72 +- .../client/models/v1_daemon_set_list.py | 72 +- .../client/models/v1_daemon_set_spec.py | 72 +- .../client/models/v1_daemon_set_status.py | 72 +- .../models/v1_daemon_set_update_strategy.py | 72 +- kubernetes/client/models/v1_delete_options.py | 72 +- kubernetes/client/models/v1_deployment.py | 72 +- .../client/models/v1_deployment_condition.py | 72 +- .../client/models/v1_deployment_list.py | 72 +- .../client/models/v1_deployment_spec.py | 72 +- .../client/models/v1_deployment_status.py | 72 +- .../client/models/v1_deployment_strategy.py | 72 +- kubernetes/client/models/v1_device.py | 72 +- .../v1_device_allocation_configuration.py | 72 +- .../models/v1_device_allocation_result.py | 72 +- .../client/models/v1_device_attribute.py | 72 +- .../client/models/v1_device_capacity.py | 72 +- kubernetes/client/models/v1_device_claim.py | 72 +- .../models/v1_device_claim_configuration.py | 72 +- kubernetes/client/models/v1_device_class.py | 72 +- .../models/v1_device_class_configuration.py | 72 +- .../client/models/v1_device_class_list.py | 72 +- .../client/models/v1_device_class_spec.py | 72 +- .../client/models/v1_device_constraint.py | 72 +- .../models/v1_device_counter_consumption.py | 72 +- .../models/v1_device_derived_attribute.py | 72 +- kubernetes/client/models/v1_device_request.py | 72 +- .../v1_device_request_allocation_result.py | 72 +- .../client/models/v1_device_selector.py | 72 +- .../client/models/v1_device_sub_request.py | 72 +- kubernetes/client/models/v1_device_taint.py | 72 +- .../client/models/v1_device_taint_rule.py | 72 +- .../models/v1_device_taint_rule_list.py | 72 +- .../models/v1_device_taint_rule_spec.py | 72 +- .../models/v1_device_taint_rule_status.py | 72 +- .../client/models/v1_device_taint_selector.py | 72 +- .../client/models/v1_device_toleration.py | 72 +- .../models/v1_downward_api_projection.py | 72 +- .../models/v1_downward_api_volume_file.py | 72 +- .../models/v1_downward_api_volume_source.py | 72 +- .../models/v1_empty_dir_volume_source.py | 72 +- kubernetes/client/models/v1_endpoint.py | 72 +- .../client/models/v1_endpoint_address.py | 72 +- .../client/models/v1_endpoint_conditions.py | 72 +- kubernetes/client/models/v1_endpoint_hints.py | 72 +- kubernetes/client/models/v1_endpoint_slice.py | 72 +- .../client/models/v1_endpoint_slice_list.py | 72 +- .../client/models/v1_endpoint_subset.py | 72 +- kubernetes/client/models/v1_endpoints.py | 72 +- kubernetes/client/models/v1_endpoints_list.py | 72 +- .../client/models/v1_env_from_source.py | 72 +- kubernetes/client/models/v1_env_var.py | 72 +- kubernetes/client/models/v1_env_var_source.py | 72 +- .../client/models/v1_ephemeral_container.py | 72 +- .../models/v1_ephemeral_volume_source.py | 72 +- kubernetes/client/models/v1_event_source.py | 72 +- kubernetes/client/models/v1_eviction.py | 72 +- .../client/models/v1_eviction_responder.py | 72 +- .../client/models/v1_exact_device_request.py | 72 +- kubernetes/client/models/v1_exec_action.py | 72 +- .../v1_exempt_priority_level_configuration.py | 72 +- .../client/models/v1_expression_warning.py | 72 +- .../models/v1_external_documentation.py | 72 +- .../client/models/v1_fc_volume_source.py | 72 +- .../models/v1_field_selector_attributes.py | 72 +- .../models/v1_field_selector_requirement.py | 72 +- .../client/models/v1_file_key_selector.py | 72 +- .../v1_flex_persistent_volume_source.py | 72 +- .../client/models/v1_flex_volume_source.py | 72 +- .../client/models/v1_flocker_volume_source.py | 72 +- .../models/v1_flow_distinguisher_method.py | 72 +- kubernetes/client/models/v1_flow_schema.py | 72 +- .../client/models/v1_flow_schema_condition.py | 72 +- .../client/models/v1_flow_schema_list.py | 72 +- .../client/models/v1_flow_schema_spec.py | 72 +- .../client/models/v1_flow_schema_status.py | 72 +- kubernetes/client/models/v1_for_node.py | 72 +- kubernetes/client/models/v1_for_zone.py | 72 +- .../v1_gce_persistent_disk_volume_source.py | 72 +- .../models/v1_git_repo_volume_source.py | 72 +- .../v1_glusterfs_persistent_volume_source.py | 72 +- .../models/v1_glusterfs_volume_source.py | 72 +- kubernetes/client/models/v1_group_resource.py | 72 +- kubernetes/client/models/v1_group_subject.py | 72 +- .../models/v1_group_version_for_discovery.py | 72 +- .../client/models/v1_group_version_kind.py | 72 +- kubernetes/client/models/v1_grpc_action.py | 72 +- .../models/v1_horizontal_pod_autoscaler.py | 72 +- .../v1_horizontal_pod_autoscaler_list.py | 72 +- .../v1_horizontal_pod_autoscaler_spec.py | 72 +- .../v1_horizontal_pod_autoscaler_status.py | 72 +- kubernetes/client/models/v1_host_alias.py | 72 +- kubernetes/client/models/v1_host_ip.py | 72 +- .../models/v1_host_path_volume_source.py | 72 +- .../client/models/v1_http_get_action.py | 72 +- kubernetes/client/models/v1_http_header.py | 72 +- .../client/models/v1_http_ingress_path.py | 72 +- .../models/v1_http_ingress_rule_value.py | 72 +- .../client/models/v1_image_volume_source.py | 72 +- .../client/models/v1_image_volume_status.py | 72 +- kubernetes/client/models/v1_ingress.py | 72 +- .../client/models/v1_ingress_backend.py | 72 +- kubernetes/client/models/v1_ingress_class.py | 72 +- .../client/models/v1_ingress_class_list.py | 72 +- .../v1_ingress_class_parameters_reference.py | 72 +- .../client/models/v1_ingress_class_spec.py | 72 +- kubernetes/client/models/v1_ingress_list.py | 72 +- .../v1_ingress_load_balancer_ingress.py | 72 +- .../models/v1_ingress_load_balancer_status.py | 72 +- .../client/models/v1_ingress_port_status.py | 72 +- kubernetes/client/models/v1_ingress_rule.py | 72 +- .../models/v1_ingress_service_backend.py | 72 +- kubernetes/client/models/v1_ingress_spec.py | 72 +- kubernetes/client/models/v1_ingress_status.py | 72 +- kubernetes/client/models/v1_ingress_tls.py | 72 +- kubernetes/client/models/v1_ip_address.py | 72 +- .../client/models/v1_ip_address_list.py | 72 +- .../client/models/v1_ip_address_spec.py | 72 +- kubernetes/client/models/v1_ip_block.py | 72 +- .../v1_iscsi_persistent_volume_source.py | 72 +- .../client/models/v1_iscsi_volume_source.py | 72 +- kubernetes/client/models/v1_job.py | 72 +- kubernetes/client/models/v1_job_condition.py | 72 +- kubernetes/client/models/v1_job_list.py | 72 +- .../models/v1_job_scheduling_configuration.py | 72 +- kubernetes/client/models/v1_job_spec.py | 72 +- kubernetes/client/models/v1_job_status.py | 72 +- .../client/models/v1_job_template_spec.py | 72 +- kubernetes/client/models/v1_json_patch.py | 72 +- .../client/models/v1_json_schema_props.py | 72 +- kubernetes/client/models/v1_key_to_path.py | 72 +- kubernetes/client/models/v1_label_selector.py | 72 +- .../models/v1_label_selector_attributes.py | 72 +- .../models/v1_label_selector_requirement.py | 72 +- kubernetes/client/models/v1_lease.py | 72 +- kubernetes/client/models/v1_lease_list.py | 72 +- kubernetes/client/models/v1_lease_spec.py | 72 +- kubernetes/client/models/v1_lifecycle.py | 72 +- .../client/models/v1_lifecycle_handler.py | 72 +- kubernetes/client/models/v1_limit_range.py | 72 +- .../client/models/v1_limit_range_item.py | 72 +- .../client/models/v1_limit_range_list.py | 72 +- .../client/models/v1_limit_range_spec.py | 72 +- kubernetes/client/models/v1_limit_response.py | 72 +- ...v1_limited_priority_level_configuration.py | 72 +- .../client/models/v1_linux_container_user.py | 72 +- kubernetes/client/models/v1_list_meta.py | 72 +- .../client/models/v1_load_balancer_ingress.py | 72 +- .../client/models/v1_load_balancer_status.py | 72 +- .../models/v1_local_object_reference.py | 72 +- .../models/v1_local_subject_access_review.py | 72 +- .../client/models/v1_local_volume_source.py | 72 +- .../client/models/v1_managed_fields_entry.py | 72 +- .../client/models/v1_match_condition.py | 72 +- .../client/models/v1_match_resources.py | 72 +- .../client/models/v1_modify_volume_status.py | 72 +- .../models/v1_mutating_admission_policy.py | 72 +- .../v1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- .../v1_mutating_admission_policy_list.py | 72 +- .../v1_mutating_admission_policy_spec.py | 72 +- .../client/models/v1_mutating_webhook.py | 72 +- .../v1_mutating_webhook_configuration.py | 72 +- .../v1_mutating_webhook_configuration_list.py | 72 +- kubernetes/client/models/v1_mutation.py | 72 +- .../models/v1_named_rule_with_operations.py | 72 +- kubernetes/client/models/v1_namespace.py | 72 +- .../client/models/v1_namespace_condition.py | 72 +- kubernetes/client/models/v1_namespace_list.py | 72 +- kubernetes/client/models/v1_namespace_spec.py | 72 +- .../client/models/v1_namespace_status.py | 72 +- .../client/models/v1_network_device_data.py | 72 +- kubernetes/client/models/v1_network_policy.py | 72 +- .../models/v1_network_policy_egress_rule.py | 72 +- .../models/v1_network_policy_ingress_rule.py | 72 +- .../client/models/v1_network_policy_list.py | 72 +- .../client/models/v1_network_policy_peer.py | 72 +- .../client/models/v1_network_policy_port.py | 72 +- .../client/models/v1_network_policy_spec.py | 72 +- .../client/models/v1_nfs_volume_source.py | 72 +- kubernetes/client/models/v1_node.py | 72 +- kubernetes/client/models/v1_node_address.py | 72 +- kubernetes/client/models/v1_node_affinity.py | 72 +- .../v1_node_allocatable_mapped_resources.py | 72 +- .../models/v1_node_allocatable_mapping.py | 72 +- .../models/v1_node_allocatable_overhead.py | 72 +- .../v1_node_allocatable_overhead_resources.py | 72 +- .../models/v1_node_allocatable_resource.py | 72 +- ..._node_allocatable_resource_claim_status.py | 72 +- kubernetes/client/models/v1_node_condition.py | 72 +- .../client/models/v1_node_config_source.py | 72 +- .../client/models/v1_node_config_status.py | 72 +- .../client/models/v1_node_daemon_endpoints.py | 72 +- kubernetes/client/models/v1_node_features.py | 72 +- kubernetes/client/models/v1_node_list.py | 72 +- .../models/v1_node_pod_preemption_policy.py | 72 +- .../client/models/v1_node_runtime_handler.py | 72 +- .../v1_node_runtime_handler_features.py | 72 +- kubernetes/client/models/v1_node_selector.py | 72 +- .../models/v1_node_selector_requirement.py | 72 +- .../client/models/v1_node_selector_term.py | 72 +- kubernetes/client/models/v1_node_spec.py | 72 +- kubernetes/client/models/v1_node_status.py | 72 +- .../client/models/v1_node_swap_status.py | 72 +- .../client/models/v1_node_system_info.py | 72 +- .../models/v1_non_resource_attributes.py | 72 +- .../models/v1_non_resource_policy_rule.py | 72 +- .../client/models/v1_non_resource_rule.py | 72 +- .../client/models/v1_object_field_selector.py | 72 +- kubernetes/client/models/v1_object_meta.py | 72 +- .../client/models/v1_object_reference.py | 72 +- .../models/v1_opaque_device_configuration.py | 72 +- kubernetes/client/models/v1_overhead.py | 72 +- .../client/models/v1_owner_reference.py | 72 +- kubernetes/client/models/v1_param_kind.py | 72 +- kubernetes/client/models/v1_param_ref.py | 72 +- .../client/models/v1_parent_reference.py | 72 +- .../client/models/v1_persistent_volume.py | 72 +- .../models/v1_persistent_volume_claim.py | 72 +- .../v1_persistent_volume_claim_condition.py | 72 +- .../models/v1_persistent_volume_claim_list.py | 72 +- .../models/v1_persistent_volume_claim_spec.py | 72 +- .../v1_persistent_volume_claim_status.py | 72 +- .../v1_persistent_volume_claim_template.py | 72 +- ...1_persistent_volume_claim_volume_source.py | 72 +- .../models/v1_persistent_volume_list.py | 72 +- .../models/v1_persistent_volume_spec.py | 72 +- .../models/v1_persistent_volume_status.py | 72 +- ...v1_photon_persistent_disk_volume_source.py | 72 +- kubernetes/client/models/v1_pod.py | 72 +- kubernetes/client/models/v1_pod_affinity.py | 72 +- .../client/models/v1_pod_affinity_term.py | 72 +- .../client/models/v1_pod_anti_affinity.py | 72 +- .../models/v1_pod_certificate_projection.py | 72 +- .../models/v1_pod_certificate_request.py | 72 +- .../models/v1_pod_certificate_request_list.py | 72 +- .../models/v1_pod_certificate_request_spec.py | 72 +- .../v1_pod_certificate_request_status.py | 72 +- kubernetes/client/models/v1_pod_condition.py | 72 +- .../client/models/v1_pod_disruption_budget.py | 72 +- .../models/v1_pod_disruption_budget_list.py | 72 +- .../models/v1_pod_disruption_budget_spec.py | 72 +- .../models/v1_pod_disruption_budget_status.py | 72 +- kubernetes/client/models/v1_pod_dns_config.py | 72 +- .../client/models/v1_pod_dns_config_option.py | 72 +- .../v1_pod_extended_resource_claim_status.py | 72 +- .../client/models/v1_pod_failure_policy.py | 72 +- ...ailure_policy_on_exit_codes_requirement.py | 72 +- ...ailure_policy_on_pod_conditions_pattern.py | 72 +- .../models/v1_pod_failure_policy_rule.py | 72 +- kubernetes/client/models/v1_pod_ip.py | 72 +- kubernetes/client/models/v1_pod_list.py | 72 +- kubernetes/client/models/v1_pod_os.py | 72 +- .../client/models/v1_pod_readiness_gate.py | 72 +- .../client/models/v1_pod_resource_claim.py | 72 +- .../models/v1_pod_resource_claim_status.py | 72 +- .../client/models/v1_pod_scheduling_gate.py | 72 +- .../client/models/v1_pod_scheduling_group.py | 72 +- .../client/models/v1_pod_security_context.py | 72 +- kubernetes/client/models/v1_pod_spec.py | 72 +- kubernetes/client/models/v1_pod_status.py | 72 +- kubernetes/client/models/v1_pod_template.py | 72 +- .../client/models/v1_pod_template_list.py | 72 +- .../client/models/v1_pod_template_spec.py | 72 +- .../client/models/v1_pod_volume_health.py | 72 +- kubernetes/client/models/v1_policy_rule.py | 72 +- .../models/v1_policy_rules_with_subjects.py | 72 +- kubernetes/client/models/v1_port_status.py | 72 +- .../models/v1_portworx_volume_source.py | 72 +- kubernetes/client/models/v1_preconditions.py | 72 +- .../models/v1_preferred_scheduling_term.py | 72 +- kubernetes/client/models/v1_priority_class.py | 72 +- .../client/models/v1_priority_class_list.py | 72 +- .../models/v1_priority_level_configuration.py | 72 +- ..._priority_level_configuration_condition.py | 72 +- .../v1_priority_level_configuration_list.py | 72 +- ..._priority_level_configuration_reference.py | 72 +- .../v1_priority_level_configuration_spec.py | 72 +- .../v1_priority_level_configuration_status.py | 72 +- kubernetes/client/models/v1_probe.py | 72 +- .../models/v1_projected_volume_source.py | 72 +- .../client/models/v1_queuing_configuration.py | 72 +- .../client/models/v1_quobyte_volume_source.py | 72 +- .../models/v1_rbd_persistent_volume_source.py | 72 +- .../client/models/v1_rbd_volume_source.py | 72 +- kubernetes/client/models/v1_replica_set.py | 72 +- .../client/models/v1_replica_set_condition.py | 72 +- .../client/models/v1_replica_set_list.py | 72 +- .../client/models/v1_replica_set_spec.py | 72 +- .../client/models/v1_replica_set_status.py | 72 +- .../models/v1_replication_controller.py | 72 +- .../v1_replication_controller_condition.py | 72 +- .../models/v1_replication_controller_list.py | 72 +- .../models/v1_replication_controller_spec.py | 72 +- .../v1_replication_controller_status.py | 72 +- .../client/models/v1_resource_attributes.py | 72 +- .../v1_resource_claim_consumer_reference.py | 72 +- .../client/models/v1_resource_claim_list.py | 72 +- .../client/models/v1_resource_claim_spec.py | 72 +- .../client/models/v1_resource_claim_status.py | 72 +- .../models/v1_resource_claim_template.py | 72 +- .../models/v1_resource_claim_template_list.py | 72 +- .../models/v1_resource_claim_template_spec.py | 72 +- .../models/v1_resource_field_selector.py | 72 +- .../client/models/v1_resource_health.py | 72 +- .../client/models/v1_resource_policy_rule.py | 72 +- kubernetes/client/models/v1_resource_pool.py | 72 +- kubernetes/client/models/v1_resource_quota.py | 72 +- .../client/models/v1_resource_quota_list.py | 72 +- .../client/models/v1_resource_quota_spec.py | 72 +- .../client/models/v1_resource_quota_status.py | 72 +- .../client/models/v1_resource_requirements.py | 72 +- kubernetes/client/models/v1_resource_rule.py | 72 +- kubernetes/client/models/v1_resource_slice.py | 72 +- .../client/models/v1_resource_slice_list.py | 72 +- .../client/models/v1_resource_slice_spec.py | 72 +- .../client/models/v1_resource_status.py | 72 +- kubernetes/client/models/v1_role.py | 72 +- kubernetes/client/models/v1_role_binding.py | 72 +- .../client/models/v1_role_binding_list.py | 72 +- kubernetes/client/models/v1_role_list.py | 72 +- kubernetes/client/models/v1_role_ref.py | 72 +- .../models/v1_rolling_update_daemon_set.py | 72 +- .../models/v1_rolling_update_deployment.py | 72 +- ...v1_rolling_update_stateful_set_strategy.py | 72 +- .../client/models/v1_rule_with_operations.py | 72 +- kubernetes/client/models/v1_runtime_class.py | 72 +- .../client/models/v1_runtime_class_list.py | 72 +- kubernetes/client/models/v1_scale.py | 72 +- .../v1_scale_io_persistent_volume_source.py | 72 +- .../models/v1_scale_io_volume_source.py | 72 +- kubernetes/client/models/v1_scale_spec.py | 72 +- kubernetes/client/models/v1_scale_status.py | 72 +- kubernetes/client/models/v1_scheduling.py | 72 +- kubernetes/client/models/v1_scope_selector.py | 72 +- ...v1_scoped_resource_selector_requirement.py | 72 +- .../client/models/v1_se_linux_options.py | 72 +- .../client/models/v1_seccomp_profile.py | 72 +- kubernetes/client/models/v1_secret.py | 72 +- .../client/models/v1_secret_env_source.py | 72 +- .../client/models/v1_secret_key_selector.py | 72 +- kubernetes/client/models/v1_secret_list.py | 72 +- .../client/models/v1_secret_projection.py | 72 +- .../client/models/v1_secret_reference.py | 72 +- .../client/models/v1_secret_volume_source.py | 72 +- .../client/models/v1_security_context.py | 72 +- .../client/models/v1_selectable_field.py | 72 +- .../models/v1_self_subject_access_review.py | 72 +- .../v1_self_subject_access_review_spec.py | 72 +- .../client/models/v1_self_subject_review.py | 72 +- .../models/v1_self_subject_review_status.py | 72 +- .../models/v1_self_subject_rules_review.py | 72 +- .../v1_self_subject_rules_review_spec.py | 72 +- .../v1_server_address_by_client_cidr.py | 72 +- kubernetes/client/models/v1_service.py | 72 +- .../client/models/v1_service_account.py | 72 +- .../client/models/v1_service_account_list.py | 72 +- .../models/v1_service_account_subject.py | 72 +- .../v1_service_account_token_projection.py | 72 +- .../client/models/v1_service_backend_port.py | 72 +- kubernetes/client/models/v1_service_cidr.py | 72 +- .../client/models/v1_service_cidr_list.py | 72 +- .../client/models/v1_service_cidr_spec.py | 72 +- .../client/models/v1_service_cidr_status.py | 72 +- kubernetes/client/models/v1_service_list.py | 72 +- kubernetes/client/models/v1_service_port.py | 72 +- kubernetes/client/models/v1_service_spec.py | 72 +- kubernetes/client/models/v1_service_status.py | 72 +- .../models/v1_session_affinity_config.py | 72 +- kubernetes/client/models/v1_shard_info.py | 72 +- kubernetes/client/models/v1_sleep_action.py | 72 +- kubernetes/client/models/v1_stateful_set.py | 72 +- .../models/v1_stateful_set_condition.py | 72 +- .../client/models/v1_stateful_set_list.py | 72 +- .../client/models/v1_stateful_set_ordinals.py | 72 +- ...ersistent_volume_claim_retention_policy.py | 72 +- .../client/models/v1_stateful_set_spec.py | 72 +- .../client/models/v1_stateful_set_status.py | 72 +- .../models/v1_stateful_set_update_strategy.py | 72 +- kubernetes/client/models/v1_status.py | 72 +- kubernetes/client/models/v1_status_cause.py | 72 +- kubernetes/client/models/v1_status_details.py | 72 +- kubernetes/client/models/v1_storage_class.py | 72 +- .../client/models/v1_storage_class_list.py | 72 +- kubernetes/client/models/v1_storage_health.py | 72 +- .../models/v1_storage_health_condition.py | 72 +- .../v1_storage_os_persistent_volume_source.py | 72 +- .../models/v1_storage_os_volume_source.py | 72 +- .../models/v1_storage_version_migration.py | 72 +- .../v1_storage_version_migration_list.py | 72 +- .../v1_storage_version_migration_spec.py | 72 +- .../v1_storage_version_migration_status.py | 72 +- .../client/models/v1_subject_access_review.py | 72 +- .../models/v1_subject_access_review_spec.py | 72 +- .../models/v1_subject_access_review_status.py | 72 +- .../models/v1_subject_rules_review_status.py | 72 +- kubernetes/client/models/v1_success_policy.py | 72 +- .../client/models/v1_success_policy_rule.py | 72 +- kubernetes/client/models/v1_sysctl.py | 72 +- kubernetes/client/models/v1_taint.py | 72 +- .../client/models/v1_tcp_socket_action.py | 72 +- .../client/models/v1_token_request_spec.py | 72 +- .../client/models/v1_token_request_status.py | 72 +- kubernetes/client/models/v1_token_review.py | 72 +- .../client/models/v1_token_review_spec.py | 72 +- .../client/models/v1_token_review_status.py | 72 +- kubernetes/client/models/v1_toleration.py | 72 +- .../v1_topology_selector_label_requirement.py | 72 +- .../models/v1_topology_selector_term.py | 72 +- .../models/v1_topology_spread_constraint.py | 72 +- kubernetes/client/models/v1_type_checking.py | 72 +- .../models/v1_typed_local_object_reference.py | 72 +- .../models/v1_typed_object_reference.py | 72 +- .../models/v1_uncounted_terminated_pods.py | 72 +- kubernetes/client/models/v1_user_info.py | 72 +- kubernetes/client/models/v1_user_subject.py | 72 +- .../models/v1_validating_admission_policy.py | 72 +- .../v1_validating_admission_policy_binding.py | 72 +- ...alidating_admission_policy_binding_list.py | 72 +- ...alidating_admission_policy_binding_spec.py | 72 +- .../v1_validating_admission_policy_list.py | 72 +- .../v1_validating_admission_policy_spec.py | 72 +- .../v1_validating_admission_policy_status.py | 72 +- .../client/models/v1_validating_webhook.py | 72 +- .../v1_validating_webhook_configuration.py | 72 +- ...1_validating_webhook_configuration_list.py | 72 +- kubernetes/client/models/v1_validation.py | 72 +- .../client/models/v1_validation_rule.py | 72 +- kubernetes/client/models/v1_variable.py | 72 +- kubernetes/client/models/v1_volume.py | 72 +- .../client/models/v1_volume_attachment.py | 72 +- .../models/v1_volume_attachment_list.py | 72 +- .../models/v1_volume_attachment_source.py | 72 +- .../models/v1_volume_attachment_spec.py | 72 +- .../models/v1_volume_attachment_status.py | 72 +- .../models/v1_volume_attributes_class.py | 72 +- .../models/v1_volume_attributes_class_list.py | 72 +- kubernetes/client/models/v1_volume_device.py | 72 +- kubernetes/client/models/v1_volume_error.py | 72 +- .../models/v1_volume_health_condition.py | 72 +- .../client/models/v1_volume_health_status.py | 72 +- kubernetes/client/models/v1_volume_mount.py | 72 +- .../client/models/v1_volume_mount_status.py | 72 +- .../client/models/v1_volume_node_affinity.py | 72 +- .../client/models/v1_volume_node_resources.py | 72 +- .../client/models/v1_volume_projection.py | 72 +- .../models/v1_volume_resource_requirements.py | 72 +- kubernetes/client/models/v1_volume_status.py | 72 +- .../v1_vsphere_virtual_disk_volume_source.py | 72 +- kubernetes/client/models/v1_watch_event.py | 72 +- .../client/models/v1_webhook_conversion.py | 72 +- .../models/v1_weighted_pod_affinity_term.py | 72 +- .../v1_windows_security_context_options.py | 72 +- .../models/v1alpha1_apply_configuration.py | 72 +- kubernetes/client/models/v1alpha1_eviction.py | 72 +- .../client/models/v1alpha1_eviction_list.py | 72 +- .../models/v1alpha1_eviction_pod_reference.py | 72 +- .../models/v1alpha1_eviction_request.py | 72 +- .../models/v1alpha1_eviction_request_list.py | 72 +- ...v1alpha1_eviction_request_pod_reference.py | 72 +- .../models/v1alpha1_eviction_request_spec.py | 72 +- .../v1alpha1_eviction_request_status.py | 72 +- .../v1alpha1_eviction_request_target.py | 72 +- .../client/models/v1alpha1_eviction_spec.py | 72 +- .../client/models/v1alpha1_eviction_status.py | 72 +- .../client/models/v1alpha1_eviction_target.py | 72 +- .../client/models/v1alpha1_json_patch.py | 72 +- .../client/models/v1alpha1_match_condition.py | 72 +- .../client/models/v1alpha1_match_resources.py | 72 +- .../v1alpha1_mutating_admission_policy.py | 72 +- ...lpha1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- ...v1alpha1_mutating_admission_policy_list.py | 72 +- ...v1alpha1_mutating_admission_policy_spec.py | 72 +- kubernetes/client/models/v1alpha1_mutation.py | 72 +- .../v1alpha1_named_rule_with_operations.py | 72 +- .../client/models/v1alpha1_param_kind.py | 72 +- .../client/models/v1alpha1_param_ref.py | 72 +- .../client/models/v1alpha1_requester.py | 72 +- .../models/v1alpha1_responder_status.py | 72 +- .../models/v1alpha1_server_storage_version.py | 72 +- .../client/models/v1alpha1_storage_version.py | 72 +- .../v1alpha1_storage_version_condition.py | 72 +- .../models/v1alpha1_storage_version_list.py | 72 +- .../models/v1alpha1_storage_version_status.py | 72 +- .../models/v1alpha1_target_responder.py | 72 +- kubernetes/client/models/v1alpha1_variable.py | 72 +- .../client/models/v1alpha2_lease_candidate.py | 72 +- .../models/v1alpha2_lease_candidate_list.py | 72 +- .../models/v1alpha2_lease_candidate_spec.py | 72 +- .../v1alpha3_composite_disruption_mode.py | 72 +- ...alpha3_composite_gang_scheduling_policy.py | 72 +- .../models/v1alpha3_composite_pod_group.py | 72 +- .../v1alpha3_composite_pod_group_list.py | 72 +- ...posite_pod_group_scheduling_constraints.py | 72 +- ...3_composite_pod_group_scheduling_policy.py | 72 +- .../v1alpha3_composite_pod_group_spec.py | 72 +- .../v1alpha3_composite_pod_group_status.py | 72 +- .../v1alpha3_composite_pod_group_template.py | 72 +- .../client/models/v1alpha3_device_taint.py | 72 +- .../models/v1alpha3_device_taint_rule.py | 72 +- .../models/v1alpha3_device_taint_rule_list.py | 72 +- .../models/v1alpha3_device_taint_rule_spec.py | 72 +- .../v1alpha3_device_taint_rule_status.py | 72 +- .../models/v1alpha3_device_taint_selector.py | 72 +- .../client/models/v1alpha3_disruption_mode.py | 72 +- .../models/v1alpha3_gang_scheduling_policy.py | 72 +- .../models/v1alpha3_partition_type_status.py | 72 +- .../client/models/v1alpha3_pod_group.py | 72 +- .../client/models/v1alpha3_pod_group_list.py | 72 +- .../v1alpha3_pod_group_resource_claim.py | 72 +- ...1alpha3_pod_group_resource_claim_status.py | 72 +- ...alpha3_pod_group_scheduling_constraints.py | 72 +- .../v1alpha3_pod_group_scheduling_policy.py | 72 +- .../client/models/v1alpha3_pod_group_spec.py | 72 +- .../models/v1alpha3_pod_group_status.py | 72 +- .../models/v1alpha3_pod_group_template.py | 72 +- .../client/models/v1alpha3_pool_status.py | 72 +- .../v1alpha3_resource_pool_status_request.py | 72 +- ...lpha3_resource_pool_status_request_list.py | 72 +- ...lpha3_resource_pool_status_request_spec.py | 72 +- ...ha3_resource_pool_status_request_status.py | 72 +- .../v1alpha3_shareable_capacity_status.py | 72 +- .../v1alpha3_shareable_summary_status.py | 72 +- .../models/v1alpha3_topology_constraint.py | 72 +- .../v1alpha3_typed_local_object_reference.py | 72 +- kubernetes/client/models/v1alpha3_workload.py | 72 +- .../client/models/v1alpha3_workload_list.py | 72 +- ...pha3_workload_pod_group_disruption_mode.py | 72 +- ...rkload_pod_group_gang_scheduling_policy.py | 72 +- ...lpha3_workload_pod_group_resource_claim.py | 72 +- ...rkload_pod_group_scheduling_constraints.py | 72 +- ...a3_workload_pod_group_scheduling_policy.py | 72 +- .../models/v1alpha3_workload_reference.py | 72 +- .../client/models/v1alpha3_workload_spec.py | 72 +- .../models/v1beta1_allocated_device_status.py | 72 +- .../models/v1beta1_allocation_result.py | 72 +- .../models/v1beta1_apply_configuration.py | 72 +- .../client/models/v1beta1_basic_device.py | 72 +- .../models/v1beta1_capacity_request_policy.py | 72 +- .../v1beta1_capacity_request_policy_range.py | 72 +- .../models/v1beta1_capacity_requirements.py | 72 +- .../models/v1beta1_cel_device_selector.py | 72 +- .../models/v1beta1_cluster_trust_bundle.py | 72 +- .../v1beta1_cluster_trust_bundle_list.py | 72 +- .../v1beta1_cluster_trust_bundle_spec.py | 72 +- .../v1beta1_composite_disruption_mode.py | 72 +- ...1beta1_composite_gang_scheduling_policy.py | 72 +- ...posite_pod_group_scheduling_constraints.py | 72 +- ...1_composite_pod_group_scheduling_policy.py | 72 +- .../v1beta1_composite_pod_group_template.py | 72 +- kubernetes/client/models/v1beta1_counter.py | 72 +- .../client/models/v1beta1_counter_set.py | 72 +- kubernetes/client/models/v1beta1_device.py | 72 +- ...v1beta1_device_allocation_configuration.py | 72 +- .../v1beta1_device_allocation_result.py | 72 +- .../client/models/v1beta1_device_attribute.py | 72 +- .../client/models/v1beta1_device_capacity.py | 72 +- .../client/models/v1beta1_device_claim.py | 72 +- .../v1beta1_device_claim_configuration.py | 72 +- .../client/models/v1beta1_device_class.py | 72 +- .../v1beta1_device_class_configuration.py | 72 +- .../models/v1beta1_device_class_list.py | 72 +- .../models/v1beta1_device_class_spec.py | 72 +- .../models/v1beta1_device_constraint.py | 72 +- .../v1beta1_device_counter_consumption.py | 72 +- .../v1beta1_device_derived_attribute.py | 72 +- .../client/models/v1beta1_device_request.py | 72 +- ...1beta1_device_request_allocation_result.py | 72 +- .../client/models/v1beta1_device_selector.py | 72 +- .../models/v1beta1_device_sub_request.py | 72 +- .../client/models/v1beta1_device_taint.py | 72 +- .../models/v1beta1_device_toleration.py | 72 +- .../client/models/v1beta1_disruption_mode.py | 72 +- .../models/v1beta1_gang_scheduling_policy.py | 72 +- .../client/models/v1beta1_json_patch.py | 72 +- .../client/models/v1beta1_lease_candidate.py | 72 +- .../models/v1beta1_lease_candidate_list.py | 72 +- .../models/v1beta1_lease_candidate_spec.py | 72 +- .../client/models/v1beta1_match_condition.py | 72 +- .../client/models/v1beta1_match_resources.py | 72 +- .../v1beta1_mutating_admission_policy.py | 72 +- ...beta1_mutating_admission_policy_binding.py | 72 +- ..._mutating_admission_policy_binding_list.py | 72 +- ..._mutating_admission_policy_binding_spec.py | 72 +- .../v1beta1_mutating_admission_policy_list.py | 72 +- .../v1beta1_mutating_admission_policy_spec.py | 72 +- kubernetes/client/models/v1beta1_mutation.py | 72 +- .../v1beta1_named_rule_with_operations.py | 72 +- .../models/v1beta1_network_device_data.py | 72 +- .../v1beta1_node_allocatable_mapping.py | 72 +- .../v1beta1_node_allocatable_overhead.py | 72 +- .../v1beta1_node_allocatable_resource.py | 72 +- .../v1beta1_opaque_device_configuration.py | 72 +- .../client/models/v1beta1_param_kind.py | 72 +- kubernetes/client/models/v1beta1_param_ref.py | 72 +- .../models/v1beta1_pod_certificate_request.py | 72 +- .../v1beta1_pod_certificate_request_list.py | 72 +- .../v1beta1_pod_certificate_request_spec.py | 72 +- .../v1beta1_pod_certificate_request_status.py | 72 +- kubernetes/client/models/v1beta1_pod_group.py | 72 +- .../client/models/v1beta1_pod_group_list.py | 72 +- .../v1beta1_pod_group_resource_claim.py | 72 +- ...v1beta1_pod_group_resource_claim_status.py | 72 +- ...1beta1_pod_group_scheduling_constraints.py | 72 +- .../v1beta1_pod_group_scheduling_policy.py | 72 +- .../client/models/v1beta1_pod_group_spec.py | 72 +- .../client/models/v1beta1_pod_group_status.py | 72 +- .../models/v1beta1_pod_group_template.py | 72 +- .../client/models/v1beta1_resource_claim.py | 72 +- ...beta1_resource_claim_consumer_reference.py | 72 +- .../models/v1beta1_resource_claim_list.py | 72 +- .../models/v1beta1_resource_claim_spec.py | 72 +- .../models/v1beta1_resource_claim_status.py | 72 +- .../models/v1beta1_resource_claim_template.py | 72 +- .../v1beta1_resource_claim_template_list.py | 72 +- .../v1beta1_resource_claim_template_spec.py | 72 +- .../client/models/v1beta1_resource_pool.py | 72 +- .../client/models/v1beta1_resource_slice.py | 72 +- .../models/v1beta1_resource_slice_list.py | 72 +- .../models/v1beta1_resource_slice_spec.py | 72 +- .../v1beta1_storage_version_migration.py | 72 +- .../v1beta1_storage_version_migration_list.py | 72 +- .../v1beta1_storage_version_migration_spec.py | 72 +- ...1beta1_storage_version_migration_status.py | 72 +- .../models/v1beta1_topology_constraint.py | 72 +- .../v1beta1_typed_local_object_reference.py | 72 +- kubernetes/client/models/v1beta1_variable.py | 72 +- kubernetes/client/models/v1beta1_workload.py | 72 +- .../client/models/v1beta1_workload_list.py | 72 +- .../models/v1beta1_workload_reference.py | 72 +- .../client/models/v1beta1_workload_spec.py | 72 +- .../models/v1beta2_allocated_device_status.py | 72 +- .../models/v1beta2_allocation_result.py | 72 +- .../models/v1beta2_capacity_request_policy.py | 72 +- .../v1beta2_capacity_request_policy_range.py | 72 +- .../models/v1beta2_capacity_requirements.py | 72 +- .../models/v1beta2_cel_device_selector.py | 72 +- kubernetes/client/models/v1beta2_counter.py | 72 +- .../client/models/v1beta2_counter_set.py | 72 +- kubernetes/client/models/v1beta2_device.py | 72 +- ...v1beta2_device_allocation_configuration.py | 72 +- .../v1beta2_device_allocation_result.py | 72 +- .../client/models/v1beta2_device_attribute.py | 72 +- .../client/models/v1beta2_device_capacity.py | 72 +- .../client/models/v1beta2_device_claim.py | 72 +- .../v1beta2_device_claim_configuration.py | 72 +- .../client/models/v1beta2_device_class.py | 72 +- .../v1beta2_device_class_configuration.py | 72 +- .../models/v1beta2_device_class_list.py | 72 +- .../models/v1beta2_device_class_spec.py | 72 +- .../models/v1beta2_device_constraint.py | 72 +- .../v1beta2_device_counter_consumption.py | 72 +- .../v1beta2_device_derived_attribute.py | 72 +- .../client/models/v1beta2_device_request.py | 72 +- ...1beta2_device_request_allocation_result.py | 72 +- .../client/models/v1beta2_device_selector.py | 72 +- .../models/v1beta2_device_sub_request.py | 72 +- .../client/models/v1beta2_device_taint.py | 72 +- .../models/v1beta2_device_taint_rule.py | 72 +- .../models/v1beta2_device_taint_rule_list.py | 72 +- .../models/v1beta2_device_taint_rule_spec.py | 72 +- .../v1beta2_device_taint_rule_status.py | 72 +- .../models/v1beta2_device_taint_selector.py | 72 +- .../models/v1beta2_device_toleration.py | 72 +- .../models/v1beta2_exact_device_request.py | 72 +- .../models/v1beta2_network_device_data.py | 72 +- .../v1beta2_node_allocatable_mapping.py | 72 +- .../v1beta2_node_allocatable_overhead.py | 72 +- .../v1beta2_node_allocatable_resource.py | 72 +- .../v1beta2_opaque_device_configuration.py | 72 +- .../client/models/v1beta2_resource_claim.py | 72 +- ...beta2_resource_claim_consumer_reference.py | 72 +- .../models/v1beta2_resource_claim_list.py | 72 +- .../models/v1beta2_resource_claim_spec.py | 72 +- .../models/v1beta2_resource_claim_status.py | 72 +- .../models/v1beta2_resource_claim_template.py | 72 +- .../v1beta2_resource_claim_template_list.py | 72 +- .../v1beta2_resource_claim_template_spec.py | 72 +- .../client/models/v1beta2_resource_pool.py | 72 +- .../client/models/v1beta2_resource_slice.py | 72 +- .../models/v1beta2_resource_slice_list.py | 72 +- .../models/v1beta2_resource_slice_spec.py | 72 +- .../client/models/v2_api_group_discovery.py | 72 +- .../models/v2_api_group_discovery_list.py | 72 +- .../models/v2_api_resource_discovery.py | 72 +- .../models/v2_api_subresource_discovery.py | 72 +- .../client/models/v2_api_version_discovery.py | 72 +- .../v2_container_resource_metric_source.py | 72 +- .../v2_container_resource_metric_status.py | 72 +- .../v2_cross_version_object_reference.py | 72 +- .../models/v2_external_metric_source.py | 72 +- .../models/v2_external_metric_status.py | 72 +- .../models/v2_horizontal_pod_autoscaler.py | 72 +- .../v2_horizontal_pod_autoscaler_behavior.py | 72 +- .../v2_horizontal_pod_autoscaler_condition.py | 72 +- .../v2_horizontal_pod_autoscaler_list.py | 72 +- .../v2_horizontal_pod_autoscaler_spec.py | 72 +- .../v2_horizontal_pod_autoscaler_status.py | 72 +- .../client/models/v2_hpa_scaling_policy.py | 72 +- .../client/models/v2_hpa_scaling_rules.py | 72 +- .../client/models/v2_metric_identifier.py | 72 +- kubernetes/client/models/v2_metric_spec.py | 72 +- kubernetes/client/models/v2_metric_status.py | 72 +- kubernetes/client/models/v2_metric_target.py | 72 +- .../client/models/v2_metric_value_status.py | 72 +- .../client/models/v2_object_metric_source.py | 72 +- .../client/models/v2_object_metric_status.py | 72 +- .../client/models/v2_pods_metric_source.py | 72 +- .../client/models/v2_pods_metric_status.py | 72 +- .../models/v2_resource_metric_source.py | 72 +- .../models/v2_resource_metric_status.py | 72 +- .../models/v2beta1_api_group_discovery.py | 72 +- .../v2beta1_api_group_discovery_list.py | 72 +- .../models/v2beta1_api_resource_discovery.py | 72 +- .../v2beta1_api_subresource_discovery.py | 72 +- .../models/v2beta1_api_version_discovery.py | 72 +- kubernetes/client/models/version_info.py | 72 +- kubernetes/client/rest.py | 2 +- kubernetes/test/test_legacy_model_helpers.py | 96 ++ scripts/client_go_retry_asyncio_patch.diff | 3 +- scripts/constants.py | 3 + scripts/update-client-asyncio.sh | 2 + scripts/update-client.sh | 2 + 1842 files changed, 15252 insertions(+), 116221 deletions(-) create mode 100644 devel/measure-package-size.py create mode 100644 kubernetes/aio/client/_legacy_model_helpers.py create mode 100644 kubernetes/client/_legacy_model_helpers.py create mode 100644 kubernetes/test/test_legacy_model_helpers.py diff --git a/devel/measure-package-size.py b/devel/measure-package-size.py new file mode 100644 index 0000000000..2a9baba9f8 --- /dev/null +++ b/devel/measure-package-size.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# Copyright 2026 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Measure release wheel sizes without installing it or its dependencies. + +Run with a Python environment containing setuptools and wheel. Pass the same +interpreter and separate clean checkouts to compare revisions. Sizes count +file contents, not filesystem allocation; bytecode uses optimization level 0. +""" + +import argparse +import compileall +import json +from pathlib import Path +import subprocess +import sys +import tempfile +import zipfile + + +def measure(root): + with tempfile.TemporaryDirectory(prefix="kubernetes-size-") as tmp: + temp = Path(tmp) + result = subprocess.run( + [sys.executable, "setup-release.py", "bdist_wheel", + "--dist-dir", str(temp / "dist"), + "--bdist-dir", str(temp / "build")], + cwd=root, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + text=True, + ) + if result.returncode: + sys.stderr.write(result.stdout) + result.check_returncode() + wheel = next((temp / "dist").glob("*.whl")) + installed = temp / "installed" + with zipfile.ZipFile(wheel) as archive: + archive.extractall(installed) + source_bytes = sum( + entry.file_size for entry in archive.infolist() + if entry.filename.endswith(".py") + ) + installed_bytes = sum( + entry.file_size for entry in archive.infolist() + ) + if not compileall.compile_dir( + installed, quiet=2, force=True, stripdir=str(installed), optimize=0, + ): + raise RuntimeError("Wheel bytecode compilation failed") + bytecode_bytes = sum( + path.stat().st_size for path in installed.rglob("*.pyc") + ) + return { + "python": sys.version.split()[0], + "source_bytes": source_bytes, + "wheel_bytes": wheel.stat().st_size, + "installed_no_compile_bytes": installed_bytes, + "bytecode_bytes": bytecode_bytes, + "installed_with_bytecode_bytes": installed_bytes + bytecode_bytes, + } + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("checkout", type=Path, help="Client repository root") + args = parser.parse_args() + print(json.dumps(measure(args.checkout.resolve()), indent=2)) diff --git a/kubernetes/.openapi-generator/COMMIT b/kubernetes/.openapi-generator/COMMIT index 20cd2af4a1..c88bb252a6 100644 --- a/kubernetes/.openapi-generator/COMMIT +++ b/kubernetes/.openapi-generator/COMMIT @@ -1,2 +1,2 @@ -Requested Commit/Tag : v7.25.0 -Actual Commit : ef964b04480889ef86b56cfae84ade8ad4c91c41 +Requested Commit/Tag : 3cf4b374881ed853d522d67b326428e09defcf29 +Actual Commit : 3cf4b374881ed853d522d67b326428e09defcf29 diff --git a/kubernetes/.openapi-generator/FILES b/kubernetes/.openapi-generator/FILES index f94c156fe4..3bb7c36f38 100644 --- a/kubernetes/.openapi-generator/FILES +++ b/kubernetes/.openapi-generator/FILES @@ -1,5 +1,6 @@ README.md client/__init__.py +client/_legacy_model_helpers.py client/api/__init__.py client/api/admissionregistration_api.py client/api/admissionregistration_v1_api.py diff --git a/kubernetes/.openapi-generator/VERSION b/kubernetes/.openapi-generator/VERSION index bc34d81264..56fe0e8b29 100644 --- a/kubernetes/.openapi-generator/VERSION +++ b/kubernetes/.openapi-generator/VERSION @@ -1 +1 @@ -7.25.0 +7.27.0-SNAPSHOT diff --git a/kubernetes/README.md b/kubernetes/README.md index 4e12cd8550..9fb7e87d82 100644 --- a/kubernetes/README.md +++ b/kubernetes/README.md @@ -5,13 +5,18 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: release-1.37 - Package version: 37.0.0+snapshot -- Generator version: 7.25.0 +- Generator version: 7.27.0-SNAPSHOT - Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. Python 3.10+ +Packaging uses standard `[project]` metadata and `[dependency-groups]` (PEP 621/735). +Install the package with `python -m pip install .`; install development dependencies +with Poetry 2.2 or newer using `poetry install`, or pip 25.1 or newer using +`python -m pip install --group dev`. The latter installs the group, not the package. + ## Installation & Usage ### pip install @@ -1980,3 +1985,36 @@ Authentication schemes defined for the API: ## Author + + + + +## Request headers + +Header names are compared case-insensitively in all Python client libraries. +Request headers are copied; supplying `_headers` does not change the caller's dict +or the client's shared defaults. The public `_headers` argument retains its dict +validation and existing value serialization. Pydantic can coerce mappings such as HTTPX `Headers` to a dict, +combining repeated fields into a single value; `_headers` does not provide a +repeated-field or list-of-pairs API. + +Precedence, from lowest to highest: + +1. `_headers` (within one dict, the last inserted case variant wins). +2. Explicit OpenAPI header parameters and generated `Content-Type` (or `_content_type`). + Generated `Accept` is added only when neither `_headers` nor explicit header + parameters contain an `Accept` case variant. +3. `ApiClient.default_headers` (including headers set with `set_default_header`). +4. The client's `cookie` setting, for `Cookie`. +5. Authentication headers. A non-empty `_request_auth` replaces configured + authentication for that call; `{}` retains configured authentication. Cookie + authentication appends to the selected `Cookie` value. + +This retains the existing precedence for identically spelled names and extends it +to case variants. To override a generated content type, use `_content_type`; +client defaults still take precedence over it. The winning header's spelling and +value are retained for replacements. Cookie authentication uses the canonical +`Cookie` spelling and appends its value. Values containing legitimate +comma-separated lists are not split or deduplicated. This does not remove +duplicate values inside a header or change the handling of repeated fields +supplied directly to the transport. diff --git a/kubernetes/aio/.openapi-generator/COMMIT b/kubernetes/aio/.openapi-generator/COMMIT index 20cd2af4a1..c88bb252a6 100644 --- a/kubernetes/aio/.openapi-generator/COMMIT +++ b/kubernetes/aio/.openapi-generator/COMMIT @@ -1,2 +1,2 @@ -Requested Commit/Tag : v7.25.0 -Actual Commit : ef964b04480889ef86b56cfae84ade8ad4c91c41 +Requested Commit/Tag : 3cf4b374881ed853d522d67b326428e09defcf29 +Actual Commit : 3cf4b374881ed853d522d67b326428e09defcf29 diff --git a/kubernetes/aio/.openapi-generator/FILES b/kubernetes/aio/.openapi-generator/FILES index f94c156fe4..3bb7c36f38 100644 --- a/kubernetes/aio/.openapi-generator/FILES +++ b/kubernetes/aio/.openapi-generator/FILES @@ -1,5 +1,6 @@ README.md client/__init__.py +client/_legacy_model_helpers.py client/api/__init__.py client/api/admissionregistration_api.py client/api/admissionregistration_v1_api.py diff --git a/kubernetes/aio/.openapi-generator/VERSION b/kubernetes/aio/.openapi-generator/VERSION index bc34d81264..56fe0e8b29 100644 --- a/kubernetes/aio/.openapi-generator/VERSION +++ b/kubernetes/aio/.openapi-generator/VERSION @@ -1 +1 @@ -7.25.0 +7.27.0-SNAPSHOT diff --git a/kubernetes/aio/README.md b/kubernetes/aio/README.md index a6a28e0a64..7a0756f01b 100644 --- a/kubernetes/aio/README.md +++ b/kubernetes/aio/README.md @@ -5,13 +5,18 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: release-1.37 - Package version: 37.0.0+snapshot -- Generator version: 7.25.0 +- Generator version: 7.27.0-SNAPSHOT - Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. Python 3.10+ +Packaging uses standard `[project]` metadata and `[dependency-groups]` (PEP 621/735). +Install the package with `python -m pip install .`; install development dependencies +with Poetry 2.2 or newer using `poetry install`, or pip 25.1 or newer using +`python -m pip install --group dev`. The latter installs the group, not the package. + ## Installation & Usage ### pip install @@ -1980,3 +1985,36 @@ Authentication schemes defined for the API: ## Author + + + + +## Request headers + +Header names are compared case-insensitively in all Python client libraries. +Request headers are copied; supplying `_headers` does not change the caller's dict +or the client's shared defaults. The public `_headers` argument retains its dict +validation and existing value serialization. Pydantic can coerce mappings such as HTTPX `Headers` to a dict, +combining repeated fields into a single value; `_headers` does not provide a +repeated-field or list-of-pairs API. + +Precedence, from lowest to highest: + +1. `_headers` (within one dict, the last inserted case variant wins). +2. Explicit OpenAPI header parameters and generated `Content-Type` (or `_content_type`). + Generated `Accept` is added only when neither `_headers` nor explicit header + parameters contain an `Accept` case variant. +3. `ApiClient.default_headers` (including headers set with `set_default_header`). +4. The client's `cookie` setting, for `Cookie`. +5. Authentication headers. A non-empty `_request_auth` replaces configured + authentication for that call; `{}` retains configured authentication. Cookie + authentication appends to the selected `Cookie` value. + +This retains the existing precedence for identically spelled names and extends it +to case variants. To override a generated content type, use `_content_type`; +client defaults still take precedence over it. The winning header's spelling and +value are retained for replacements. Cookie authentication uses the canonical +`Cookie` spelling and appends its value. Values containing legitimate +comma-separated lists are not split or deduplicated. This does not remove +duplicate values inside a header or change the handling of repeated fields +supplied directly to the transport. diff --git a/kubernetes/aio/client/_legacy_model_helpers.py b/kubernetes/aio/client/_legacy_model_helpers.py new file mode 100644 index 0000000000..24d63d6111 --- /dev/null +++ b/kubernetes/aio/client/_legacy_model_helpers.py @@ -0,0 +1,80 @@ +""" + Kubernetes + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: release-1.37 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from typing import Any + +_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" + + +def _get_openapi_to_dict(value: Any) -> Any: + # Reciprocal function references preserve inherited generated methods + # without reserving model member names. Checking both directions also + # rejects overrides whose decorators copy function attributes. + to_dict = getattr(value, "to_dict", None) + type_to_dict = getattr(type(value), "to_dict", None) + if ( + not callable(to_dict) + or getattr(to_dict, "__func__", None) is not type_to_dict + ): + return None + + openapi_to_dict = getattr( + type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None + ) + if ( + not callable(openapi_to_dict) + or getattr( + openapi_to_dict, + _OPENAPI_GENERATOR_TO_DICT, + None, + ) is not type_to_dict + ): + return None + return openapi_to_dict + + +def _to_legacy_item(value: Any, serialize: bool) -> Any: + to_dict = getattr(value, "to_dict", None) + if _get_openapi_to_dict(value) is not None and callable(to_dict): + return to_dict(serialize=serialize) + if callable(to_dict): + return to_dict() + return value + + +def _to_legacy_value(value: Any, serialize: bool) -> Any: + # python-legacy converted only immediate list elements or dictionary values: + # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 + if isinstance(value, list): + return [_to_legacy_item(item, serialize) for item in value] + if isinstance(value, dict): + return { + key: _to_legacy_item(item, serialize) + for key, item in value.items() + } + return _to_legacy_item(value, serialize) + + +def _to_openapi_value(value: Any) -> Any: + if isinstance(value, list): + return [_to_openapi_value(item) for item in value] + if isinstance(value, dict): + return {key: _to_openapi_value(item) for key, item in value.items()} + + to_openapi_dict = _get_openapi_to_dict(value) + if to_openapi_dict is not None: + return to_openapi_dict(value) + + to_dict = getattr(value, "to_dict", None) + if callable(to_dict): + return to_dict() + return value diff --git a/kubernetes/aio/client/api/admissionregistration_api.py b/kubernetes/aio/client/api/admissionregistration_api.py index 9437195ec0..0841bbf63a 100644 --- a/kubernetes/aio/client/api/admissionregistration_api.py +++ b/kubernetes/aio/client/api/admissionregistration_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/admissionregistration_v1_api.py b/kubernetes/aio/client/api/admissionregistration_v1_api.py index e19362df2a..225b0ae5fd 100644 --- a/kubernetes/aio/client/api/admissionregistration_v1_api.py +++ b/kubernetes/aio/client/api/admissionregistration_v1_api.py @@ -346,7 +346,7 @@ async def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -379,7 +379,7 @@ async def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -688,7 +688,7 @@ async def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -721,7 +721,7 @@ async def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1030,7 +1030,7 @@ async def _create_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1063,7 +1063,7 @@ async def _create_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1372,7 +1372,7 @@ async def _create_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1405,7 +1405,7 @@ async def _create_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1714,7 +1714,7 @@ async def _create_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1747,7 +1747,7 @@ async def _create_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2056,7 +2056,7 @@ async def _create_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2089,7 +2089,7 @@ async def _create_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2535,7 +2535,7 @@ async def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2612,7 +2612,7 @@ async def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3058,7 +3058,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3135,7 +3135,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3581,7 +3581,7 @@ async def _delete_collection_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3658,7 +3658,7 @@ async def _delete_collection_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4104,7 +4104,7 @@ async def _delete_collection_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4181,7 +4181,7 @@ async def _delete_collection_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4627,7 +4627,7 @@ async def _delete_collection_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4704,7 +4704,7 @@ async def _delete_collection_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5150,7 +5150,7 @@ async def _delete_collection_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5227,7 +5227,7 @@ async def _delete_collection_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5572,7 +5572,7 @@ async def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5615,7 +5615,7 @@ async def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5960,7 +5960,7 @@ async def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6003,7 +6003,7 @@ async def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6348,7 +6348,7 @@ async def _delete_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6391,7 +6391,7 @@ async def _delete_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6736,7 +6736,7 @@ async def _delete_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6779,7 +6779,7 @@ async def _delete_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7124,7 +7124,7 @@ async def _delete_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7167,7 +7167,7 @@ async def _delete_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7512,7 +7512,7 @@ async def _delete_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7555,7 +7555,7 @@ async def _delete_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7793,7 +7793,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7808,7 +7808,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8202,7 +8202,7 @@ async def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8265,7 +8265,7 @@ async def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8662,7 +8662,7 @@ async def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8725,7 +8725,7 @@ async def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9122,7 +9122,7 @@ async def _list_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9185,7 +9185,7 @@ async def _list_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9582,7 +9582,7 @@ async def _list_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9645,7 +9645,7 @@ async def _list_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10042,7 +10042,7 @@ async def _list_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10105,7 +10105,7 @@ async def _list_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10502,7 +10502,7 @@ async def _list_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10565,7 +10565,7 @@ async def _list_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10900,7 +10900,7 @@ async def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10939,7 +10939,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10951,7 +10951,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10965,7 +10965,7 @@ async def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11288,7 +11288,7 @@ async def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11327,7 +11327,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11339,7 +11339,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11353,7 +11353,7 @@ async def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11676,7 +11676,7 @@ async def _patch_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11715,7 +11715,7 @@ async def _patch_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11727,7 +11727,7 @@ async def _patch_mutating_webhook_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11741,7 +11741,7 @@ async def _patch_mutating_webhook_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12064,7 +12064,7 @@ async def _patch_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12103,7 +12103,7 @@ async def _patch_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12115,7 +12115,7 @@ async def _patch_validating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12129,7 +12129,7 @@ async def _patch_validating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12452,7 +12452,7 @@ async def _patch_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12491,7 +12491,7 @@ async def _patch_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12503,7 +12503,7 @@ async def _patch_validating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12517,7 +12517,7 @@ async def _patch_validating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12840,7 +12840,7 @@ async def _patch_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12879,7 +12879,7 @@ async def _patch_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12891,7 +12891,7 @@ async def _patch_validating_admission_policy_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12905,7 +12905,7 @@ async def _patch_validating_admission_policy_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13228,7 +13228,7 @@ async def _patch_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13267,7 +13267,7 @@ async def _patch_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13279,7 +13279,7 @@ async def _patch_validating_webhook_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13293,7 +13293,7 @@ async def _patch_validating_webhook_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13548,7 +13548,7 @@ async def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13569,7 +13569,7 @@ async def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13833,7 +13833,7 @@ async def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13854,7 +13854,7 @@ async def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14118,7 +14118,7 @@ async def _read_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14139,7 +14139,7 @@ async def _read_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14403,7 +14403,7 @@ async def _read_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14424,7 +14424,7 @@ async def _read_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14688,7 +14688,7 @@ async def _read_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14709,7 +14709,7 @@ async def _read_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14973,7 +14973,7 @@ async def _read_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14994,7 +14994,7 @@ async def _read_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15258,7 +15258,7 @@ async def _read_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15279,7 +15279,7 @@ async def _read_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15598,7 +15598,7 @@ async def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15633,7 +15633,7 @@ async def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15952,7 +15952,7 @@ async def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15987,7 +15987,7 @@ async def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16306,7 +16306,7 @@ async def _replace_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16341,7 +16341,7 @@ async def _replace_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16660,7 +16660,7 @@ async def _replace_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16695,7 +16695,7 @@ async def _replace_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17014,7 +17014,7 @@ async def _replace_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17049,7 +17049,7 @@ async def _replace_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17368,7 +17368,7 @@ async def _replace_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17403,7 +17403,7 @@ async def _replace_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17722,7 +17722,7 @@ async def _replace_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17757,7 +17757,7 @@ async def _replace_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/admissionregistration_v1alpha1_api.py b/kubernetes/aio/client/api/admissionregistration_v1alpha1_api.py index f36e8c8719..a81b21a852 100644 --- a/kubernetes/aio/client/api/admissionregistration_v1alpha1_api.py +++ b/kubernetes/aio/client/api/admissionregistration_v1alpha1_api.py @@ -338,7 +338,7 @@ async def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -371,7 +371,7 @@ async def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -680,7 +680,7 @@ async def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -713,7 +713,7 @@ async def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1159,7 +1159,7 @@ async def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1236,7 +1236,7 @@ async def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1682,7 +1682,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1759,7 +1759,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2104,7 +2104,7 @@ async def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2147,7 +2147,7 @@ async def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2492,7 +2492,7 @@ async def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2535,7 +2535,7 @@ async def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2773,7 +2773,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2788,7 +2788,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3182,7 +3182,7 @@ async def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3245,7 +3245,7 @@ async def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3642,7 +3642,7 @@ async def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3705,7 +3705,7 @@ async def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4040,7 +4040,7 @@ async def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4079,7 +4079,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4091,7 +4091,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4105,7 +4105,7 @@ async def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4428,7 +4428,7 @@ async def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4467,7 +4467,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4479,7 +4479,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4493,7 +4493,7 @@ async def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4748,7 +4748,7 @@ async def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4769,7 +4769,7 @@ async def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5033,7 +5033,7 @@ async def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5054,7 +5054,7 @@ async def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5373,7 +5373,7 @@ async def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5408,7 +5408,7 @@ async def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5727,7 +5727,7 @@ async def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5762,7 +5762,7 @@ async def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/admissionregistration_v1beta1_api.py b/kubernetes/aio/client/api/admissionregistration_v1beta1_api.py index 30070f9607..46209974f9 100644 --- a/kubernetes/aio/client/api/admissionregistration_v1beta1_api.py +++ b/kubernetes/aio/client/api/admissionregistration_v1beta1_api.py @@ -338,7 +338,7 @@ async def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -371,7 +371,7 @@ async def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -680,7 +680,7 @@ async def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -713,7 +713,7 @@ async def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1159,7 +1159,7 @@ async def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1236,7 +1236,7 @@ async def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1682,7 +1682,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1759,7 +1759,7 @@ async def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2104,7 +2104,7 @@ async def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2147,7 +2147,7 @@ async def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2492,7 +2492,7 @@ async def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2535,7 +2535,7 @@ async def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2773,7 +2773,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2788,7 +2788,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3182,7 +3182,7 @@ async def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3245,7 +3245,7 @@ async def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3642,7 +3642,7 @@ async def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3705,7 +3705,7 @@ async def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4040,7 +4040,7 @@ async def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4079,7 +4079,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4091,7 +4091,7 @@ async def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4105,7 +4105,7 @@ async def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4428,7 +4428,7 @@ async def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4467,7 +4467,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4479,7 +4479,7 @@ async def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4493,7 +4493,7 @@ async def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4748,7 +4748,7 @@ async def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4769,7 +4769,7 @@ async def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5033,7 +5033,7 @@ async def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5054,7 +5054,7 @@ async def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5373,7 +5373,7 @@ async def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5408,7 +5408,7 @@ async def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5727,7 +5727,7 @@ async def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5762,7 +5762,7 @@ async def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apiextensions_api.py b/kubernetes/aio/client/api/apiextensions_api.py index b1f90bb32e..5beb98fe03 100644 --- a/kubernetes/aio/client/api/apiextensions_api.py +++ b/kubernetes/aio/client/api/apiextensions_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apiextensions_v1_api.py b/kubernetes/aio/client/api/apiextensions_v1_api.py index 0911f44926..6c9d2f2156 100644 --- a/kubernetes/aio/client/api/apiextensions_v1_api.py +++ b/kubernetes/aio/client/api/apiextensions_v1_api.py @@ -336,7 +336,7 @@ async def _create_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_custom_resource_definition_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_custom_resource_definition_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2713,7 +2713,7 @@ async def _patch_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2752,7 +2752,7 @@ async def _patch_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2764,7 +2764,7 @@ async def _patch_custom_resource_definition_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2778,7 +2778,7 @@ async def _patch_custom_resource_definition_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3033,7 +3033,7 @@ async def _read_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3054,7 +3054,7 @@ async def _read_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3318,7 +3318,7 @@ async def _read_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3339,7 +3339,7 @@ async def _read_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3658,7 +3658,7 @@ async def _replace_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3693,7 +3693,7 @@ async def _replace_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4012,7 +4012,7 @@ async def _replace_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4047,7 +4047,7 @@ async def _replace_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apiregistration_api.py b/kubernetes/aio/client/api/apiregistration_api.py index 04ad23255c..f28e53b51f 100644 --- a/kubernetes/aio/client/api/apiregistration_api.py +++ b/kubernetes/aio/client/api/apiregistration_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apiregistration_v1_api.py b/kubernetes/aio/client/api/apiregistration_v1_api.py index 5704c1e6a1..9ab804614c 100644 --- a/kubernetes/aio/client/api/apiregistration_v1_api.py +++ b/kubernetes/aio/client/api/apiregistration_v1_api.py @@ -336,7 +336,7 @@ async def _create_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -714,7 +714,7 @@ async def _delete_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -757,7 +757,7 @@ async def _delete_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1203,7 +1203,7 @@ async def _delete_collection_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_collection_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_api_service_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_api_service_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2713,7 +2713,7 @@ async def _patch_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2752,7 +2752,7 @@ async def _patch_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2764,7 +2764,7 @@ async def _patch_api_service_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2778,7 +2778,7 @@ async def _patch_api_service_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3033,7 +3033,7 @@ async def _read_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3054,7 +3054,7 @@ async def _read_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3318,7 +3318,7 @@ async def _read_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3339,7 +3339,7 @@ async def _read_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3658,7 +3658,7 @@ async def _replace_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3693,7 +3693,7 @@ async def _replace_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4012,7 +4012,7 @@ async def _replace_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4047,7 +4047,7 @@ async def _replace_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apis_api.py b/kubernetes/aio/client/api/apis_api.py index 52222959ea..e6aa1257ac 100644 --- a/kubernetes/aio/client/api/apis_api.py +++ b/kubernetes/aio/client/api/apis_api.py @@ -258,7 +258,7 @@ async def _get_api_versions_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_versions_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apps_api.py b/kubernetes/aio/client/api/apps_api.py index 5c4052d0c8..7fb97fc436 100644 --- a/kubernetes/aio/client/api/apps_api.py +++ b/kubernetes/aio/client/api/apps_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/apps_v1_api.py b/kubernetes/aio/client/api/apps_v1_api.py index a9aea2b6b8..cc56abd7f5 100644 --- a/kubernetes/aio/client/api/apps_v1_api.py +++ b/kubernetes/aio/client/api/apps_v1_api.py @@ -358,7 +358,7 @@ async def _create_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -393,7 +393,7 @@ async def _create_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -715,7 +715,7 @@ async def _create_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -750,7 +750,7 @@ async def _create_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1072,7 +1072,7 @@ async def _create_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1107,7 +1107,7 @@ async def _create_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1429,7 +1429,7 @@ async def _create_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1464,7 +1464,7 @@ async def _create_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1786,7 +1786,7 @@ async def _create_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1821,7 +1821,7 @@ async def _create_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2280,7 +2280,7 @@ async def _delete_collection_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2359,7 +2359,7 @@ async def _delete_collection_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2818,7 +2818,7 @@ async def _delete_collection_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2897,7 +2897,7 @@ async def _delete_collection_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3356,7 +3356,7 @@ async def _delete_collection_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3435,7 +3435,7 @@ async def _delete_collection_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3894,7 +3894,7 @@ async def _delete_collection_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3973,7 +3973,7 @@ async def _delete_collection_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4432,7 +4432,7 @@ async def _delete_collection_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4511,7 +4511,7 @@ async def _delete_collection_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4869,7 +4869,7 @@ async def _delete_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4914,7 +4914,7 @@ async def _delete_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5272,7 +5272,7 @@ async def _delete_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5317,7 +5317,7 @@ async def _delete_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5675,7 +5675,7 @@ async def _delete_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5720,7 +5720,7 @@ async def _delete_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6078,7 +6078,7 @@ async def _delete_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6123,7 +6123,7 @@ async def _delete_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6481,7 +6481,7 @@ async def _delete_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6526,7 +6526,7 @@ async def _delete_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6764,7 +6764,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6779,7 +6779,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7173,7 +7173,7 @@ async def _list_controller_revision_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7236,7 +7236,7 @@ async def _list_controller_revision_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7633,7 +7633,7 @@ async def _list_daemon_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7696,7 +7696,7 @@ async def _list_daemon_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8093,7 +8093,7 @@ async def _list_deployment_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8156,7 +8156,7 @@ async def _list_deployment_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8566,7 +8566,7 @@ async def _list_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8631,7 +8631,7 @@ async def _list_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9041,7 +9041,7 @@ async def _list_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9106,7 +9106,7 @@ async def _list_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9516,7 +9516,7 @@ async def _list_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9581,7 +9581,7 @@ async def _list_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9991,7 +9991,7 @@ async def _list_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10056,7 +10056,7 @@ async def _list_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10466,7 +10466,7 @@ async def _list_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10531,7 +10531,7 @@ async def _list_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10928,7 +10928,7 @@ async def _list_replica_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10991,7 +10991,7 @@ async def _list_replica_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11388,7 +11388,7 @@ async def _list_stateful_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11451,7 +11451,7 @@ async def _list_stateful_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11799,7 +11799,7 @@ async def _patch_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11840,7 +11840,7 @@ async def _patch_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11852,7 +11852,7 @@ async def _patch_namespaced_controller_revision_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11866,7 +11866,7 @@ async def _patch_namespaced_controller_revision_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12202,7 +12202,7 @@ async def _patch_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12243,7 +12243,7 @@ async def _patch_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12255,7 +12255,7 @@ async def _patch_namespaced_daemon_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12269,7 +12269,7 @@ async def _patch_namespaced_daemon_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12605,7 +12605,7 @@ async def _patch_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12646,7 +12646,7 @@ async def _patch_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12658,7 +12658,7 @@ async def _patch_namespaced_daemon_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12672,7 +12672,7 @@ async def _patch_namespaced_daemon_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13008,7 +13008,7 @@ async def _patch_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13049,7 +13049,7 @@ async def _patch_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13061,7 +13061,7 @@ async def _patch_namespaced_deployment_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13075,7 +13075,7 @@ async def _patch_namespaced_deployment_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13411,7 +13411,7 @@ async def _patch_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13452,7 +13452,7 @@ async def _patch_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13464,7 +13464,7 @@ async def _patch_namespaced_deployment_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13478,7 +13478,7 @@ async def _patch_namespaced_deployment_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13814,7 +13814,7 @@ async def _patch_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13855,7 +13855,7 @@ async def _patch_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13867,7 +13867,7 @@ async def _patch_namespaced_deployment_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13881,7 +13881,7 @@ async def _patch_namespaced_deployment_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -14217,7 +14217,7 @@ async def _patch_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14258,7 +14258,7 @@ async def _patch_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14270,7 +14270,7 @@ async def _patch_namespaced_replica_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -14284,7 +14284,7 @@ async def _patch_namespaced_replica_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -14620,7 +14620,7 @@ async def _patch_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14661,7 +14661,7 @@ async def _patch_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14673,7 +14673,7 @@ async def _patch_namespaced_replica_set_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -14687,7 +14687,7 @@ async def _patch_namespaced_replica_set_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -15023,7 +15023,7 @@ async def _patch_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15064,7 +15064,7 @@ async def _patch_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15076,7 +15076,7 @@ async def _patch_namespaced_replica_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -15090,7 +15090,7 @@ async def _patch_namespaced_replica_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -15426,7 +15426,7 @@ async def _patch_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15467,7 +15467,7 @@ async def _patch_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15479,7 +15479,7 @@ async def _patch_namespaced_stateful_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -15493,7 +15493,7 @@ async def _patch_namespaced_stateful_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -15829,7 +15829,7 @@ async def _patch_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15870,7 +15870,7 @@ async def _patch_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15882,7 +15882,7 @@ async def _patch_namespaced_stateful_set_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -15896,7 +15896,7 @@ async def _patch_namespaced_stateful_set_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -16232,7 +16232,7 @@ async def _patch_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16273,7 +16273,7 @@ async def _patch_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16285,7 +16285,7 @@ async def _patch_namespaced_stateful_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -16299,7 +16299,7 @@ async def _patch_namespaced_stateful_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -16567,7 +16567,7 @@ async def _read_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16590,7 +16590,7 @@ async def _read_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16867,7 +16867,7 @@ async def _read_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16890,7 +16890,7 @@ async def _read_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17167,7 +17167,7 @@ async def _read_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17190,7 +17190,7 @@ async def _read_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17467,7 +17467,7 @@ async def _read_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17490,7 +17490,7 @@ async def _read_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17767,7 +17767,7 @@ async def _read_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17790,7 +17790,7 @@ async def _read_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18067,7 +18067,7 @@ async def _read_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18090,7 +18090,7 @@ async def _read_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18367,7 +18367,7 @@ async def _read_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18390,7 +18390,7 @@ async def _read_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18667,7 +18667,7 @@ async def _read_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18690,7 +18690,7 @@ async def _read_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18967,7 +18967,7 @@ async def _read_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18990,7 +18990,7 @@ async def _read_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19267,7 +19267,7 @@ async def _read_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19290,7 +19290,7 @@ async def _read_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19567,7 +19567,7 @@ async def _read_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19590,7 +19590,7 @@ async def _read_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19867,7 +19867,7 @@ async def _read_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19890,7 +19890,7 @@ async def _read_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20222,7 +20222,7 @@ async def _replace_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20259,7 +20259,7 @@ async def _replace_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20591,7 +20591,7 @@ async def _replace_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20628,7 +20628,7 @@ async def _replace_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20960,7 +20960,7 @@ async def _replace_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20997,7 +20997,7 @@ async def _replace_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21329,7 +21329,7 @@ async def _replace_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21366,7 +21366,7 @@ async def _replace_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21698,7 +21698,7 @@ async def _replace_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21735,7 +21735,7 @@ async def _replace_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22067,7 +22067,7 @@ async def _replace_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22104,7 +22104,7 @@ async def _replace_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22436,7 +22436,7 @@ async def _replace_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22473,7 +22473,7 @@ async def _replace_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22805,7 +22805,7 @@ async def _replace_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22842,7 +22842,7 @@ async def _replace_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23174,7 +23174,7 @@ async def _replace_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23211,7 +23211,7 @@ async def _replace_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23543,7 +23543,7 @@ async def _replace_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23580,7 +23580,7 @@ async def _replace_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23912,7 +23912,7 @@ async def _replace_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23949,7 +23949,7 @@ async def _replace_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24281,7 +24281,7 @@ async def _replace_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24318,7 +24318,7 @@ async def _replace_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/authentication_api.py b/kubernetes/aio/client/api/authentication_api.py index 8f1e416a54..f53067da90 100644 --- a/kubernetes/aio/client/api/authentication_api.py +++ b/kubernetes/aio/client/api/authentication_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/authentication_v1_api.py b/kubernetes/aio/client/api/authentication_v1_api.py index f07d331f39..c8c9ac01dd 100644 --- a/kubernetes/aio/client/api/authentication_v1_api.py +++ b/kubernetes/aio/client/api/authentication_v1_api.py @@ -334,7 +334,7 @@ async def _create_self_subject_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -367,7 +367,7 @@ async def _create_self_subject_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -676,7 +676,7 @@ async def _create_token_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -709,7 +709,7 @@ async def _create_token_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -947,7 +947,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -962,7 +962,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/authorization_api.py b/kubernetes/aio/client/api/authorization_api.py index 05fe399716..0227e6f29a 100644 --- a/kubernetes/aio/client/api/authorization_api.py +++ b/kubernetes/aio/client/api/authorization_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/authorization_v1_api.py b/kubernetes/aio/client/api/authorization_v1_api.py index c39bf81877..2150d7a65b 100644 --- a/kubernetes/aio/client/api/authorization_v1_api.py +++ b/kubernetes/aio/client/api/authorization_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_local_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_local_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -693,7 +693,7 @@ async def _create_self_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -726,7 +726,7 @@ async def _create_self_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1035,7 +1035,7 @@ async def _create_self_subject_rules_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1068,7 +1068,7 @@ async def _create_self_subject_rules_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1377,7 +1377,7 @@ async def _create_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1410,7 +1410,7 @@ async def _create_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1648,7 +1648,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1663,7 +1663,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/autoscaling_api.py b/kubernetes/aio/client/api/autoscaling_api.py index 3006589ea2..eba1da0838 100644 --- a/kubernetes/aio/client/api/autoscaling_api.py +++ b/kubernetes/aio/client/api/autoscaling_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/autoscaling_v1_api.py b/kubernetes/aio/client/api/autoscaling_v1_api.py index d6272b9c77..a555753b22 100644 --- a/kubernetes/aio/client/api/autoscaling_v1_api.py +++ b/kubernetes/aio/client/api/autoscaling_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3261,7 +3261,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3302,7 +3302,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3314,7 +3314,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3328,7 +3328,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3596,7 +3596,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3619,7 +3619,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3896,7 +3896,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3919,7 +3919,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4251,7 +4251,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4288,7 +4288,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4620,7 +4620,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4657,7 +4657,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/autoscaling_v2_api.py b/kubernetes/aio/client/api/autoscaling_v2_api.py index 8d9ea17fd4..377d21e339 100644 --- a/kubernetes/aio/client/api/autoscaling_v2_api.py +++ b/kubernetes/aio/client/api/autoscaling_v2_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3261,7 +3261,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3302,7 +3302,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3314,7 +3314,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3328,7 +3328,7 @@ async def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3596,7 +3596,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3619,7 +3619,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3896,7 +3896,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3919,7 +3919,7 @@ async def _read_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4251,7 +4251,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4288,7 +4288,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4620,7 +4620,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4657,7 +4657,7 @@ async def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/batch_api.py b/kubernetes/aio/client/api/batch_api.py index 4391221d98..174d189f7f 100644 --- a/kubernetes/aio/client/api/batch_api.py +++ b/kubernetes/aio/client/api/batch_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/batch_v1_api.py b/kubernetes/aio/client/api/batch_v1_api.py index 373935bda3..6d4072ab52 100644 --- a/kubernetes/aio/client/api/batch_v1_api.py +++ b/kubernetes/aio/client/api/batch_v1_api.py @@ -351,7 +351,7 @@ async def _create_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -386,7 +386,7 @@ async def _create_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -708,7 +708,7 @@ async def _create_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -743,7 +743,7 @@ async def _create_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1202,7 +1202,7 @@ async def _delete_collection_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1281,7 +1281,7 @@ async def _delete_collection_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1740,7 +1740,7 @@ async def _delete_collection_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1819,7 +1819,7 @@ async def _delete_collection_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2177,7 +2177,7 @@ async def _delete_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2222,7 +2222,7 @@ async def _delete_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2580,7 +2580,7 @@ async def _delete_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2625,7 +2625,7 @@ async def _delete_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2863,7 +2863,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2878,7 +2878,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3272,7 +3272,7 @@ async def _list_cron_job_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3335,7 +3335,7 @@ async def _list_cron_job_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3732,7 +3732,7 @@ async def _list_job_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3795,7 +3795,7 @@ async def _list_job_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4205,7 +4205,7 @@ async def _list_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4270,7 +4270,7 @@ async def _list_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4680,7 +4680,7 @@ async def _list_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4745,7 +4745,7 @@ async def _list_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5093,7 +5093,7 @@ async def _patch_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5134,7 +5134,7 @@ async def _patch_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5146,7 +5146,7 @@ async def _patch_namespaced_cron_job_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5160,7 +5160,7 @@ async def _patch_namespaced_cron_job_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5496,7 +5496,7 @@ async def _patch_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5537,7 +5537,7 @@ async def _patch_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5549,7 +5549,7 @@ async def _patch_namespaced_cron_job_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5563,7 +5563,7 @@ async def _patch_namespaced_cron_job_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5899,7 +5899,7 @@ async def _patch_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5940,7 +5940,7 @@ async def _patch_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5952,7 +5952,7 @@ async def _patch_namespaced_job_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5966,7 +5966,7 @@ async def _patch_namespaced_job_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6302,7 +6302,7 @@ async def _patch_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6343,7 +6343,7 @@ async def _patch_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6355,7 +6355,7 @@ async def _patch_namespaced_job_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6369,7 +6369,7 @@ async def _patch_namespaced_job_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6637,7 +6637,7 @@ async def _read_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6660,7 +6660,7 @@ async def _read_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6937,7 +6937,7 @@ async def _read_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6960,7 +6960,7 @@ async def _read_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7237,7 +7237,7 @@ async def _read_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7260,7 +7260,7 @@ async def _read_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7537,7 +7537,7 @@ async def _read_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7560,7 +7560,7 @@ async def _read_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7892,7 +7892,7 @@ async def _replace_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7929,7 +7929,7 @@ async def _replace_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8261,7 +8261,7 @@ async def _replace_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8298,7 +8298,7 @@ async def _replace_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8630,7 +8630,7 @@ async def _replace_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8667,7 +8667,7 @@ async def _replace_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8999,7 +8999,7 @@ async def _replace_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9036,7 +9036,7 @@ async def _replace_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/certificates_api.py b/kubernetes/aio/client/api/certificates_api.py index d2a447b3f8..0c414563f5 100644 --- a/kubernetes/aio/client/api/certificates_api.py +++ b/kubernetes/aio/client/api/certificates_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/certificates_v1_api.py b/kubernetes/aio/client/api/certificates_v1_api.py index a76aebbf98..b329e65a2e 100644 --- a/kubernetes/aio/client/api/certificates_v1_api.py +++ b/kubernetes/aio/client/api/certificates_v1_api.py @@ -340,7 +340,7 @@ async def _create_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -373,7 +373,7 @@ async def _create_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -682,7 +682,7 @@ async def _create_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -715,7 +715,7 @@ async def _create_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1037,7 +1037,7 @@ async def _create_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1072,7 +1072,7 @@ async def _create_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1417,7 +1417,7 @@ async def _delete_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1460,7 +1460,7 @@ async def _delete_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1805,7 +1805,7 @@ async def _delete_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1848,7 +1848,7 @@ async def _delete_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2294,7 +2294,7 @@ async def _delete_collection_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2371,7 +2371,7 @@ async def _delete_collection_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2817,7 +2817,7 @@ async def _delete_collection_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2894,7 +2894,7 @@ async def _delete_collection_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3353,7 +3353,7 @@ async def _delete_collection_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3432,7 +3432,7 @@ async def _delete_collection_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3790,7 +3790,7 @@ async def _delete_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3835,7 +3835,7 @@ async def _delete_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4073,7 +4073,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4088,7 +4088,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4482,7 +4482,7 @@ async def _list_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4545,7 +4545,7 @@ async def _list_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4942,7 +4942,7 @@ async def _list_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5005,7 +5005,7 @@ async def _list_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5415,7 +5415,7 @@ async def _list_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5480,7 +5480,7 @@ async def _list_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5877,7 +5877,7 @@ async def _list_pod_certificate_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5940,7 +5940,7 @@ async def _list_pod_certificate_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6275,7 +6275,7 @@ async def _patch_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6314,7 +6314,7 @@ async def _patch_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6326,7 +6326,7 @@ async def _patch_certificate_signing_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6340,7 +6340,7 @@ async def _patch_certificate_signing_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6663,7 +6663,7 @@ async def _patch_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6702,7 +6702,7 @@ async def _patch_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6714,7 +6714,7 @@ async def _patch_certificate_signing_request_approval_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6728,7 +6728,7 @@ async def _patch_certificate_signing_request_approval_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7051,7 +7051,7 @@ async def _patch_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7090,7 +7090,7 @@ async def _patch_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7102,7 +7102,7 @@ async def _patch_certificate_signing_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7116,7 +7116,7 @@ async def _patch_certificate_signing_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7439,7 +7439,7 @@ async def _patch_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7478,7 +7478,7 @@ async def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7490,7 +7490,7 @@ async def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7504,7 +7504,7 @@ async def _patch_cluster_trust_bundle_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7840,7 +7840,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7881,7 +7881,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7893,7 +7893,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7907,7 +7907,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8243,7 +8243,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8284,7 +8284,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8296,7 +8296,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8310,7 +8310,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8565,7 +8565,7 @@ async def _read_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8586,7 +8586,7 @@ async def _read_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8850,7 +8850,7 @@ async def _read_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8871,7 +8871,7 @@ async def _read_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9135,7 +9135,7 @@ async def _read_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9156,7 +9156,7 @@ async def _read_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9420,7 +9420,7 @@ async def _read_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9441,7 +9441,7 @@ async def _read_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9718,7 +9718,7 @@ async def _read_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9741,7 +9741,7 @@ async def _read_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10018,7 +10018,7 @@ async def _read_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10041,7 +10041,7 @@ async def _read_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10360,7 +10360,7 @@ async def _replace_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10395,7 +10395,7 @@ async def _replace_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10714,7 +10714,7 @@ async def _replace_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10749,7 +10749,7 @@ async def _replace_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11068,7 +11068,7 @@ async def _replace_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11103,7 +11103,7 @@ async def _replace_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11422,7 +11422,7 @@ async def _replace_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11457,7 +11457,7 @@ async def _replace_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11789,7 +11789,7 @@ async def _replace_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11826,7 +11826,7 @@ async def _replace_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12158,7 +12158,7 @@ async def _replace_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12195,7 +12195,7 @@ async def _replace_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/certificates_v1beta1_api.py b/kubernetes/aio/client/api/certificates_v1beta1_api.py index 19c3ea6926..e906b17bc6 100644 --- a/kubernetes/aio/client/api/certificates_v1beta1_api.py +++ b/kubernetes/aio/client/api/certificates_v1beta1_api.py @@ -338,7 +338,7 @@ async def _create_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -371,7 +371,7 @@ async def _create_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -693,7 +693,7 @@ async def _create_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -728,7 +728,7 @@ async def _create_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1073,7 +1073,7 @@ async def _delete_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1116,7 +1116,7 @@ async def _delete_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1562,7 +1562,7 @@ async def _delete_collection_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1639,7 +1639,7 @@ async def _delete_collection_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2098,7 +2098,7 @@ async def _delete_collection_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2177,7 +2177,7 @@ async def _delete_collection_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2535,7 +2535,7 @@ async def _delete_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2580,7 +2580,7 @@ async def _delete_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2818,7 +2818,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2833,7 +2833,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3227,7 +3227,7 @@ async def _list_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3290,7 +3290,7 @@ async def _list_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3700,7 +3700,7 @@ async def _list_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3765,7 +3765,7 @@ async def _list_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4162,7 +4162,7 @@ async def _list_pod_certificate_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4225,7 +4225,7 @@ async def _list_pod_certificate_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4560,7 +4560,7 @@ async def _patch_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4599,7 +4599,7 @@ async def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4611,7 +4611,7 @@ async def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4625,7 +4625,7 @@ async def _patch_cluster_trust_bundle_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4961,7 +4961,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5002,7 +5002,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5014,7 +5014,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5028,7 +5028,7 @@ async def _patch_namespaced_pod_certificate_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5364,7 +5364,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5405,7 +5405,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5417,7 +5417,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5431,7 +5431,7 @@ async def _patch_namespaced_pod_certificate_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5686,7 +5686,7 @@ async def _read_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5707,7 +5707,7 @@ async def _read_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5984,7 +5984,7 @@ async def _read_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6007,7 +6007,7 @@ async def _read_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6284,7 +6284,7 @@ async def _read_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6307,7 +6307,7 @@ async def _read_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6626,7 +6626,7 @@ async def _replace_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6661,7 +6661,7 @@ async def _replace_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6993,7 +6993,7 @@ async def _replace_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7030,7 +7030,7 @@ async def _replace_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7362,7 +7362,7 @@ async def _replace_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7399,7 +7399,7 @@ async def _replace_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/coordination_api.py b/kubernetes/aio/client/api/coordination_api.py index a21d5de8ce..d19a76b25e 100644 --- a/kubernetes/aio/client/api/coordination_api.py +++ b/kubernetes/aio/client/api/coordination_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/coordination_v1_api.py b/kubernetes/aio/client/api/coordination_v1_api.py index ebd0d5815e..96743eee21 100644 --- a/kubernetes/aio/client/api/coordination_v1_api.py +++ b/kubernetes/aio/client/api/coordination_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_lease_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_lease_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_lease_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_lease_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3193,7 +3193,7 @@ async def _read_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3216,7 +3216,7 @@ async def _read_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3548,7 +3548,7 @@ async def _replace_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ async def _replace_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/coordination_v1alpha2_api.py b/kubernetes/aio/client/api/coordination_v1alpha2_api.py index e857f76c4d..981adf8e43 100644 --- a/kubernetes/aio/client/api/coordination_v1alpha2_api.py +++ b/kubernetes/aio/client/api/coordination_v1alpha2_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_lease_candidate_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_lease_candidate_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_lease_candidate_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3193,7 +3193,7 @@ async def _read_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3216,7 +3216,7 @@ async def _read_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3548,7 +3548,7 @@ async def _replace_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ async def _replace_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/coordination_v1beta1_api.py b/kubernetes/aio/client/api/coordination_v1beta1_api.py index 6401a62ccd..3d0836ea14 100644 --- a/kubernetes/aio/client/api/coordination_v1beta1_api.py +++ b/kubernetes/aio/client/api/coordination_v1beta1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_lease_candidate_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_lease_candidate_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_lease_candidate_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3193,7 +3193,7 @@ async def _read_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3216,7 +3216,7 @@ async def _read_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3548,7 +3548,7 @@ async def _replace_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ async def _replace_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/core_api.py b/kubernetes/aio/client/api/core_api.py index 93d0333efa..d21c42d25b 100644 --- a/kubernetes/aio/client/api/core_api.py +++ b/kubernetes/aio/client/api/core_api.py @@ -258,7 +258,7 @@ async def _get_api_versions_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_versions_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/core_v1_api.py b/kubernetes/aio/client/api/core_v1_api.py index 467f91f4cc..6aa5ddb7f4 100644 --- a/kubernetes/aio/client/api/core_v1_api.py +++ b/kubernetes/aio/client/api/core_v1_api.py @@ -338,7 +338,7 @@ async def _connect_delete_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -361,7 +361,7 @@ async def _connect_delete_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -648,7 +648,7 @@ async def _connect_delete_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -673,7 +673,7 @@ async def _connect_delete_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -947,7 +947,7 @@ async def _connect_delete_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -970,7 +970,7 @@ async def _connect_delete_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1257,7 +1257,7 @@ async def _connect_delete_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1282,7 +1282,7 @@ async def _connect_delete_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1543,7 +1543,7 @@ async def _connect_delete_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1564,7 +1564,7 @@ async def _connect_delete_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1838,7 +1838,7 @@ async def _connect_delete_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1861,7 +1861,7 @@ async def _connect_delete_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2187,7 +2187,7 @@ async def _connect_get_namespaced_pod_attach_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2226,7 +2226,7 @@ async def _connect_get_namespaced_pod_attach_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2566,7 +2566,7 @@ async def _connect_get_namespaced_pod_exec_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2609,7 +2609,7 @@ async def _connect_get_namespaced_pod_exec_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2883,7 +2883,7 @@ async def _connect_get_namespaced_pod_portforward_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2906,7 +2906,7 @@ async def _connect_get_namespaced_pod_portforward_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3180,7 +3180,7 @@ async def _connect_get_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3203,7 +3203,7 @@ async def _connect_get_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3490,7 +3490,7 @@ async def _connect_get_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3515,7 +3515,7 @@ async def _connect_get_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3789,7 +3789,7 @@ async def _connect_get_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3812,7 +3812,7 @@ async def _connect_get_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4099,7 +4099,7 @@ async def _connect_get_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4124,7 +4124,7 @@ async def _connect_get_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4385,7 +4385,7 @@ async def _connect_get_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4406,7 +4406,7 @@ async def _connect_get_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4680,7 +4680,7 @@ async def _connect_get_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4703,7 +4703,7 @@ async def _connect_get_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4977,7 +4977,7 @@ async def _connect_head_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5000,7 +5000,7 @@ async def _connect_head_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5287,7 +5287,7 @@ async def _connect_head_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5312,7 +5312,7 @@ async def _connect_head_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5586,7 +5586,7 @@ async def _connect_head_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5609,7 +5609,7 @@ async def _connect_head_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5896,7 +5896,7 @@ async def _connect_head_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5921,7 +5921,7 @@ async def _connect_head_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6182,7 +6182,7 @@ async def _connect_head_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6203,7 +6203,7 @@ async def _connect_head_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6477,7 +6477,7 @@ async def _connect_head_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6500,7 +6500,7 @@ async def _connect_head_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6774,7 +6774,7 @@ async def _connect_options_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6797,7 +6797,7 @@ async def _connect_options_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7084,7 +7084,7 @@ async def _connect_options_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7109,7 +7109,7 @@ async def _connect_options_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7383,7 +7383,7 @@ async def _connect_options_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7406,7 +7406,7 @@ async def _connect_options_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7693,7 +7693,7 @@ async def _connect_options_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7718,7 +7718,7 @@ async def _connect_options_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7979,7 +7979,7 @@ async def _connect_options_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8000,7 +8000,7 @@ async def _connect_options_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8274,7 +8274,7 @@ async def _connect_options_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8297,7 +8297,7 @@ async def _connect_options_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8571,7 +8571,7 @@ async def _connect_patch_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8594,7 +8594,7 @@ async def _connect_patch_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8881,7 +8881,7 @@ async def _connect_patch_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8906,7 +8906,7 @@ async def _connect_patch_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9180,7 +9180,7 @@ async def _connect_patch_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9203,7 +9203,7 @@ async def _connect_patch_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9490,7 +9490,7 @@ async def _connect_patch_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9515,7 +9515,7 @@ async def _connect_patch_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9776,7 +9776,7 @@ async def _connect_patch_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9797,7 +9797,7 @@ async def _connect_patch_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10071,7 +10071,7 @@ async def _connect_patch_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10094,7 +10094,7 @@ async def _connect_patch_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10420,7 +10420,7 @@ async def _connect_post_namespaced_pod_attach_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10459,7 +10459,7 @@ async def _connect_post_namespaced_pod_attach_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10799,7 +10799,7 @@ async def _connect_post_namespaced_pod_exec_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10842,7 +10842,7 @@ async def _connect_post_namespaced_pod_exec_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11116,7 +11116,7 @@ async def _connect_post_namespaced_pod_portforward_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11139,7 +11139,7 @@ async def _connect_post_namespaced_pod_portforward_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11413,7 +11413,7 @@ async def _connect_post_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11436,7 +11436,7 @@ async def _connect_post_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11723,7 +11723,7 @@ async def _connect_post_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11748,7 +11748,7 @@ async def _connect_post_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12022,7 +12022,7 @@ async def _connect_post_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12045,7 +12045,7 @@ async def _connect_post_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12332,7 +12332,7 @@ async def _connect_post_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12357,7 +12357,7 @@ async def _connect_post_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12618,7 +12618,7 @@ async def _connect_post_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12639,7 +12639,7 @@ async def _connect_post_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12913,7 +12913,7 @@ async def _connect_post_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12936,7 +12936,7 @@ async def _connect_post_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -13210,7 +13210,7 @@ async def _connect_put_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13233,7 +13233,7 @@ async def _connect_put_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -13520,7 +13520,7 @@ async def _connect_put_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13545,7 +13545,7 @@ async def _connect_put_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -13819,7 +13819,7 @@ async def _connect_put_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13842,7 +13842,7 @@ async def _connect_put_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -14129,7 +14129,7 @@ async def _connect_put_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14154,7 +14154,7 @@ async def _connect_put_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -14415,7 +14415,7 @@ async def _connect_put_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14436,7 +14436,7 @@ async def _connect_put_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -14710,7 +14710,7 @@ async def _connect_put_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14733,7 +14733,7 @@ async def _connect_put_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -15039,7 +15039,7 @@ async def _create_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15072,7 +15072,7 @@ async def _create_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15394,7 +15394,7 @@ async def _create_namespaced_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15429,7 +15429,7 @@ async def _create_namespaced_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15751,7 +15751,7 @@ async def _create_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15786,7 +15786,7 @@ async def _create_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16108,7 +16108,7 @@ async def _create_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16143,7 +16143,7 @@ async def _create_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16465,7 +16465,7 @@ async def _create_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16500,7 +16500,7 @@ async def _create_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16822,7 +16822,7 @@ async def _create_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16857,7 +16857,7 @@ async def _create_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17179,7 +17179,7 @@ async def _create_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17214,7 +17214,7 @@ async def _create_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17536,7 +17536,7 @@ async def _create_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17571,7 +17571,7 @@ async def _create_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17906,7 +17906,7 @@ async def _create_namespaced_pod_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17943,7 +17943,7 @@ async def _create_namespaced_pod_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18278,7 +18278,7 @@ async def _create_namespaced_pod_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18315,7 +18315,7 @@ async def _create_namespaced_pod_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18637,7 +18637,7 @@ async def _create_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18672,7 +18672,7 @@ async def _create_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18994,7 +18994,7 @@ async def _create_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19029,7 +19029,7 @@ async def _create_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19351,7 +19351,7 @@ async def _create_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19386,7 +19386,7 @@ async def _create_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19708,7 +19708,7 @@ async def _create_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19743,7 +19743,7 @@ async def _create_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20065,7 +20065,7 @@ async def _create_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20100,7 +20100,7 @@ async def _create_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20422,7 +20422,7 @@ async def _create_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20457,7 +20457,7 @@ async def _create_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20792,7 +20792,7 @@ async def _create_namespaced_service_account_token_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20829,7 +20829,7 @@ async def _create_namespaced_service_account_token_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21138,7 +21138,7 @@ async def _create_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21171,7 +21171,7 @@ async def _create_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21480,7 +21480,7 @@ async def _create_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21513,7 +21513,7 @@ async def _create_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21972,7 +21972,7 @@ async def _delete_collection_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22051,7 +22051,7 @@ async def _delete_collection_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22510,7 +22510,7 @@ async def _delete_collection_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22589,7 +22589,7 @@ async def _delete_collection_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23048,7 +23048,7 @@ async def _delete_collection_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23127,7 +23127,7 @@ async def _delete_collection_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23586,7 +23586,7 @@ async def _delete_collection_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23665,7 +23665,7 @@ async def _delete_collection_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24124,7 +24124,7 @@ async def _delete_collection_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24203,7 +24203,7 @@ async def _delete_collection_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24662,7 +24662,7 @@ async def _delete_collection_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24741,7 +24741,7 @@ async def _delete_collection_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -25200,7 +25200,7 @@ async def _delete_collection_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -25279,7 +25279,7 @@ async def _delete_collection_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -25738,7 +25738,7 @@ async def _delete_collection_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -25817,7 +25817,7 @@ async def _delete_collection_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -26276,7 +26276,7 @@ async def _delete_collection_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -26355,7 +26355,7 @@ async def _delete_collection_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -26814,7 +26814,7 @@ async def _delete_collection_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -26893,7 +26893,7 @@ async def _delete_collection_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -27352,7 +27352,7 @@ async def _delete_collection_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27431,7 +27431,7 @@ async def _delete_collection_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -27890,7 +27890,7 @@ async def _delete_collection_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27969,7 +27969,7 @@ async def _delete_collection_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -28415,7 +28415,7 @@ async def _delete_collection_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -28492,7 +28492,7 @@ async def _delete_collection_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -28938,7 +28938,7 @@ async def _delete_collection_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29015,7 +29015,7 @@ async def _delete_collection_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -29360,7 +29360,7 @@ async def _delete_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29403,7 +29403,7 @@ async def _delete_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -29761,7 +29761,7 @@ async def _delete_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29806,7 +29806,7 @@ async def _delete_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -30164,7 +30164,7 @@ async def _delete_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -30209,7 +30209,7 @@ async def _delete_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -30567,7 +30567,7 @@ async def _delete_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -30612,7 +30612,7 @@ async def _delete_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -30970,7 +30970,7 @@ async def _delete_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31015,7 +31015,7 @@ async def _delete_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -31373,7 +31373,7 @@ async def _delete_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31418,7 +31418,7 @@ async def _delete_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -31776,7 +31776,7 @@ async def _delete_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31821,7 +31821,7 @@ async def _delete_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32179,7 +32179,7 @@ async def _delete_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -32224,7 +32224,7 @@ async def _delete_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32582,7 +32582,7 @@ async def _delete_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -32627,7 +32627,7 @@ async def _delete_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32985,7 +32985,7 @@ async def _delete_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -33030,7 +33030,7 @@ async def _delete_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -33388,7 +33388,7 @@ async def _delete_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -33433,7 +33433,7 @@ async def _delete_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -33791,7 +33791,7 @@ async def _delete_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -33836,7 +33836,7 @@ async def _delete_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34194,7 +34194,7 @@ async def _delete_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -34239,7 +34239,7 @@ async def _delete_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34584,7 +34584,7 @@ async def _delete_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -34627,7 +34627,7 @@ async def _delete_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34972,7 +34972,7 @@ async def _delete_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -35015,7 +35015,7 @@ async def _delete_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -35253,7 +35253,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -35268,7 +35268,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -35662,7 +35662,7 @@ async def _list_component_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -35725,7 +35725,7 @@ async def _list_component_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -36122,7 +36122,7 @@ async def _list_config_map_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -36185,7 +36185,7 @@ async def _list_config_map_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -36582,7 +36582,7 @@ async def _list_endpoints_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -36645,7 +36645,7 @@ async def _list_endpoints_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37042,7 +37042,7 @@ async def _list_event_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -37105,7 +37105,7 @@ async def _list_event_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37502,7 +37502,7 @@ async def _list_limit_range_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -37565,7 +37565,7 @@ async def _list_limit_range_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37962,7 +37962,7 @@ async def _list_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -38025,7 +38025,7 @@ async def _list_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -38435,7 +38435,7 @@ async def _list_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -38500,7 +38500,7 @@ async def _list_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -38910,7 +38910,7 @@ async def _list_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -38975,7 +38975,7 @@ async def _list_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -39385,7 +39385,7 @@ async def _list_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -39450,7 +39450,7 @@ async def _list_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -39860,7 +39860,7 @@ async def _list_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -39925,7 +39925,7 @@ async def _list_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -40335,7 +40335,7 @@ async def _list_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -40400,7 +40400,7 @@ async def _list_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -40810,7 +40810,7 @@ async def _list_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -40875,7 +40875,7 @@ async def _list_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -41285,7 +41285,7 @@ async def _list_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -41350,7 +41350,7 @@ async def _list_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -41760,7 +41760,7 @@ async def _list_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -41825,7 +41825,7 @@ async def _list_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -42235,7 +42235,7 @@ async def _list_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -42300,7 +42300,7 @@ async def _list_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -42710,7 +42710,7 @@ async def _list_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -42775,7 +42775,7 @@ async def _list_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -43185,7 +43185,7 @@ async def _list_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -43250,7 +43250,7 @@ async def _list_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -43660,7 +43660,7 @@ async def _list_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -43725,7 +43725,7 @@ async def _list_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -44122,7 +44122,7 @@ async def _list_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44185,7 +44185,7 @@ async def _list_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -44582,7 +44582,7 @@ async def _list_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44645,7 +44645,7 @@ async def _list_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45042,7 +45042,7 @@ async def _list_persistent_volume_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -45105,7 +45105,7 @@ async def _list_persistent_volume_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45502,7 +45502,7 @@ async def _list_pod_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -45565,7 +45565,7 @@ async def _list_pod_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45962,7 +45962,7 @@ async def _list_pod_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46025,7 +46025,7 @@ async def _list_pod_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -46422,7 +46422,7 @@ async def _list_replication_controller_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46485,7 +46485,7 @@ async def _list_replication_controller_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -46882,7 +46882,7 @@ async def _list_resource_quota_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46945,7 +46945,7 @@ async def _list_resource_quota_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -47342,7 +47342,7 @@ async def _list_secret_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -47405,7 +47405,7 @@ async def _list_secret_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -47802,7 +47802,7 @@ async def _list_service_account_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -47865,7 +47865,7 @@ async def _list_service_account_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48262,7 +48262,7 @@ async def _list_service_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48325,7 +48325,7 @@ async def _list_service_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48660,7 +48660,7 @@ async def _patch_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48699,7 +48699,7 @@ async def _patch_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48711,7 +48711,7 @@ async def _patch_namespace_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -48725,7 +48725,7 @@ async def _patch_namespace_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -49048,7 +49048,7 @@ async def _patch_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49087,7 +49087,7 @@ async def _patch_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49099,7 +49099,7 @@ async def _patch_namespace_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -49113,7 +49113,7 @@ async def _patch_namespace_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -49449,7 +49449,7 @@ async def _patch_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49490,7 +49490,7 @@ async def _patch_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49502,7 +49502,7 @@ async def _patch_namespaced_config_map_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -49516,7 +49516,7 @@ async def _patch_namespaced_config_map_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -49852,7 +49852,7 @@ async def _patch_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49893,7 +49893,7 @@ async def _patch_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49905,7 +49905,7 @@ async def _patch_namespaced_endpoints_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -49919,7 +49919,7 @@ async def _patch_namespaced_endpoints_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -50255,7 +50255,7 @@ async def _patch_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -50296,7 +50296,7 @@ async def _patch_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50308,7 +50308,7 @@ async def _patch_namespaced_event_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -50322,7 +50322,7 @@ async def _patch_namespaced_event_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -50658,7 +50658,7 @@ async def _patch_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -50699,7 +50699,7 @@ async def _patch_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50711,7 +50711,7 @@ async def _patch_namespaced_limit_range_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -50725,7 +50725,7 @@ async def _patch_namespaced_limit_range_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -51061,7 +51061,7 @@ async def _patch_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51102,7 +51102,7 @@ async def _patch_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51114,7 +51114,7 @@ async def _patch_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -51128,7 +51128,7 @@ async def _patch_namespaced_persistent_volume_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -51464,7 +51464,7 @@ async def _patch_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51505,7 +51505,7 @@ async def _patch_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51517,7 +51517,7 @@ async def _patch_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -51531,7 +51531,7 @@ async def _patch_namespaced_persistent_volume_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -51867,7 +51867,7 @@ async def _patch_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51908,7 +51908,7 @@ async def _patch_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51920,7 +51920,7 @@ async def _patch_namespaced_pod_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -51934,7 +51934,7 @@ async def _patch_namespaced_pod_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -52270,7 +52270,7 @@ async def _patch_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52311,7 +52311,7 @@ async def _patch_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52323,7 +52323,7 @@ async def _patch_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -52337,7 +52337,7 @@ async def _patch_namespaced_pod_ephemeralcontainers_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -52673,7 +52673,7 @@ async def _patch_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52714,7 +52714,7 @@ async def _patch_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52726,7 +52726,7 @@ async def _patch_namespaced_pod_resize_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -52740,7 +52740,7 @@ async def _patch_namespaced_pod_resize_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -53076,7 +53076,7 @@ async def _patch_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53117,7 +53117,7 @@ async def _patch_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53129,7 +53129,7 @@ async def _patch_namespaced_pod_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -53143,7 +53143,7 @@ async def _patch_namespaced_pod_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -53479,7 +53479,7 @@ async def _patch_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53520,7 +53520,7 @@ async def _patch_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53532,7 +53532,7 @@ async def _patch_namespaced_pod_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -53546,7 +53546,7 @@ async def _patch_namespaced_pod_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -53882,7 +53882,7 @@ async def _patch_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53923,7 +53923,7 @@ async def _patch_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53935,7 +53935,7 @@ async def _patch_namespaced_replication_controller_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -53949,7 +53949,7 @@ async def _patch_namespaced_replication_controller_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -54285,7 +54285,7 @@ async def _patch_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54326,7 +54326,7 @@ async def _patch_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54338,7 +54338,7 @@ async def _patch_namespaced_replication_controller_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -54352,7 +54352,7 @@ async def _patch_namespaced_replication_controller_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -54688,7 +54688,7 @@ async def _patch_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54729,7 +54729,7 @@ async def _patch_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54741,7 +54741,7 @@ async def _patch_namespaced_replication_controller_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -54755,7 +54755,7 @@ async def _patch_namespaced_replication_controller_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -55091,7 +55091,7 @@ async def _patch_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55132,7 +55132,7 @@ async def _patch_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55144,7 +55144,7 @@ async def _patch_namespaced_resource_quota_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -55158,7 +55158,7 @@ async def _patch_namespaced_resource_quota_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -55494,7 +55494,7 @@ async def _patch_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55535,7 +55535,7 @@ async def _patch_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55547,7 +55547,7 @@ async def _patch_namespaced_resource_quota_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -55561,7 +55561,7 @@ async def _patch_namespaced_resource_quota_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -55897,7 +55897,7 @@ async def _patch_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55938,7 +55938,7 @@ async def _patch_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55950,7 +55950,7 @@ async def _patch_namespaced_secret_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -55964,7 +55964,7 @@ async def _patch_namespaced_secret_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -56300,7 +56300,7 @@ async def _patch_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -56341,7 +56341,7 @@ async def _patch_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56353,7 +56353,7 @@ async def _patch_namespaced_service_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -56367,7 +56367,7 @@ async def _patch_namespaced_service_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -56703,7 +56703,7 @@ async def _patch_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -56744,7 +56744,7 @@ async def _patch_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56756,7 +56756,7 @@ async def _patch_namespaced_service_account_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -56770,7 +56770,7 @@ async def _patch_namespaced_service_account_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -57106,7 +57106,7 @@ async def _patch_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57147,7 +57147,7 @@ async def _patch_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57159,7 +57159,7 @@ async def _patch_namespaced_service_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -57173,7 +57173,7 @@ async def _patch_namespaced_service_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -57496,7 +57496,7 @@ async def _patch_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57535,7 +57535,7 @@ async def _patch_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57547,7 +57547,7 @@ async def _patch_node_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -57561,7 +57561,7 @@ async def _patch_node_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -57884,7 +57884,7 @@ async def _patch_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57923,7 +57923,7 @@ async def _patch_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57935,7 +57935,7 @@ async def _patch_node_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -57949,7 +57949,7 @@ async def _patch_node_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -58272,7 +58272,7 @@ async def _patch_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -58311,7 +58311,7 @@ async def _patch_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -58323,7 +58323,7 @@ async def _patch_persistent_volume_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -58337,7 +58337,7 @@ async def _patch_persistent_volume_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -58660,7 +58660,7 @@ async def _patch_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -58699,7 +58699,7 @@ async def _patch_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -58711,7 +58711,7 @@ async def _patch_persistent_volume_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -58725,7 +58725,7 @@ async def _patch_persistent_volume_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -58980,7 +58980,7 @@ async def _read_component_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59001,7 +59001,7 @@ async def _read_component_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59265,7 +59265,7 @@ async def _read_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59286,7 +59286,7 @@ async def _read_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59550,7 +59550,7 @@ async def _read_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59571,7 +59571,7 @@ async def _read_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59848,7 +59848,7 @@ async def _read_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59871,7 +59871,7 @@ async def _read_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60148,7 +60148,7 @@ async def _read_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60171,7 +60171,7 @@ async def _read_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60448,7 +60448,7 @@ async def _read_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60471,7 +60471,7 @@ async def _read_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60748,7 +60748,7 @@ async def _read_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60771,7 +60771,7 @@ async def _read_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61048,7 +61048,7 @@ async def _read_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61071,7 +61071,7 @@ async def _read_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61348,7 +61348,7 @@ async def _read_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61371,7 +61371,7 @@ async def _read_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61648,7 +61648,7 @@ async def _read_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61671,7 +61671,7 @@ async def _read_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61948,7 +61948,7 @@ async def _read_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61971,7 +61971,7 @@ async def _read_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -62365,7 +62365,7 @@ async def _read_namespaced_pod_log_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -62424,7 +62424,7 @@ async def _read_namespaced_pod_log_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'text/plain', @@ -62702,7 +62702,7 @@ async def _read_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -62725,7 +62725,7 @@ async def _read_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -63002,7 +63002,7 @@ async def _read_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -63025,7 +63025,7 @@ async def _read_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -63302,7 +63302,7 @@ async def _read_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -63325,7 +63325,7 @@ async def _read_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -63602,7 +63602,7 @@ async def _read_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -63625,7 +63625,7 @@ async def _read_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -63902,7 +63902,7 @@ async def _read_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -63925,7 +63925,7 @@ async def _read_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -64202,7 +64202,7 @@ async def _read_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -64225,7 +64225,7 @@ async def _read_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -64502,7 +64502,7 @@ async def _read_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -64525,7 +64525,7 @@ async def _read_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -64802,7 +64802,7 @@ async def _read_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -64825,7 +64825,7 @@ async def _read_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -65102,7 +65102,7 @@ async def _read_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -65125,7 +65125,7 @@ async def _read_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -65402,7 +65402,7 @@ async def _read_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -65425,7 +65425,7 @@ async def _read_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -65702,7 +65702,7 @@ async def _read_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -65725,7 +65725,7 @@ async def _read_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -66002,7 +66002,7 @@ async def _read_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -66025,7 +66025,7 @@ async def _read_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -66289,7 +66289,7 @@ async def _read_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -66310,7 +66310,7 @@ async def _read_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -66574,7 +66574,7 @@ async def _read_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -66595,7 +66595,7 @@ async def _read_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -66859,7 +66859,7 @@ async def _read_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -66880,7 +66880,7 @@ async def _read_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -67144,7 +67144,7 @@ async def _read_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -67165,7 +67165,7 @@ async def _read_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -67484,7 +67484,7 @@ async def _replace_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -67519,7 +67519,7 @@ async def _replace_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -67838,7 +67838,7 @@ async def _replace_namespace_finalize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -67873,7 +67873,7 @@ async def _replace_namespace_finalize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -68192,7 +68192,7 @@ async def _replace_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -68227,7 +68227,7 @@ async def _replace_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -68559,7 +68559,7 @@ async def _replace_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -68596,7 +68596,7 @@ async def _replace_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -68928,7 +68928,7 @@ async def _replace_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -68965,7 +68965,7 @@ async def _replace_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -69297,7 +69297,7 @@ async def _replace_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -69334,7 +69334,7 @@ async def _replace_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -69666,7 +69666,7 @@ async def _replace_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -69703,7 +69703,7 @@ async def _replace_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -70035,7 +70035,7 @@ async def _replace_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -70072,7 +70072,7 @@ async def _replace_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -70404,7 +70404,7 @@ async def _replace_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -70441,7 +70441,7 @@ async def _replace_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -70773,7 +70773,7 @@ async def _replace_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -70810,7 +70810,7 @@ async def _replace_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -71142,7 +71142,7 @@ async def _replace_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -71179,7 +71179,7 @@ async def _replace_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -71511,7 +71511,7 @@ async def _replace_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -71548,7 +71548,7 @@ async def _replace_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -71880,7 +71880,7 @@ async def _replace_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -71917,7 +71917,7 @@ async def _replace_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -72249,7 +72249,7 @@ async def _replace_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -72286,7 +72286,7 @@ async def _replace_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -72618,7 +72618,7 @@ async def _replace_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -72655,7 +72655,7 @@ async def _replace_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -72987,7 +72987,7 @@ async def _replace_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -73024,7 +73024,7 @@ async def _replace_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -73356,7 +73356,7 @@ async def _replace_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -73393,7 +73393,7 @@ async def _replace_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -73725,7 +73725,7 @@ async def _replace_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -73762,7 +73762,7 @@ async def _replace_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -74094,7 +74094,7 @@ async def _replace_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -74131,7 +74131,7 @@ async def _replace_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -74463,7 +74463,7 @@ async def _replace_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -74500,7 +74500,7 @@ async def _replace_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -74832,7 +74832,7 @@ async def _replace_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -74869,7 +74869,7 @@ async def _replace_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -75201,7 +75201,7 @@ async def _replace_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -75238,7 +75238,7 @@ async def _replace_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -75570,7 +75570,7 @@ async def _replace_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -75607,7 +75607,7 @@ async def _replace_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -75926,7 +75926,7 @@ async def _replace_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -75961,7 +75961,7 @@ async def _replace_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -76280,7 +76280,7 @@ async def _replace_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -76315,7 +76315,7 @@ async def _replace_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -76634,7 +76634,7 @@ async def _replace_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -76669,7 +76669,7 @@ async def _replace_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -76988,7 +76988,7 @@ async def _replace_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -77023,7 +77023,7 @@ async def _replace_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/custom_objects_api.py b/kubernetes/aio/client/api/custom_objects_api.py index 42cfb00b57..08aa18aa23 100644 --- a/kubernetes/aio/client/api/custom_objects_api.py +++ b/kubernetes/aio/client/api/custom_objects_api.py @@ -366,7 +366,7 @@ async def _create_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -405,7 +405,7 @@ async def _create_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -757,7 +757,7 @@ async def _create_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -798,7 +798,7 @@ async def _create_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1150,7 +1150,7 @@ async def _delete_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1191,7 +1191,7 @@ async def _delete_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1556,7 +1556,7 @@ async def _delete_collection_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1603,7 +1603,7 @@ async def _delete_collection_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1994,7 +1994,7 @@ async def _delete_collection_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2047,7 +2047,7 @@ async def _delete_collection_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -2412,7 +2412,7 @@ async def _delete_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2455,7 +2455,7 @@ async def _delete_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -2716,7 +2716,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2735,7 +2735,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -3022,7 +3022,7 @@ async def _get_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3045,7 +3045,7 @@ async def _get_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -3332,7 +3332,7 @@ async def _get_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3355,7 +3355,7 @@ async def _get_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3644,7 +3644,7 @@ async def _get_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3667,7 +3667,7 @@ async def _get_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3969,7 +3969,7 @@ async def _get_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3994,7 +3994,7 @@ async def _get_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -4294,7 +4294,7 @@ async def _get_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4319,7 +4319,7 @@ async def _get_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4621,7 +4621,7 @@ async def _get_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4646,7 +4646,7 @@ async def _get_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5052,7 +5052,7 @@ async def _list_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5113,7 +5113,7 @@ async def _list_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5518,7 +5518,7 @@ async def _list_custom_object_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5579,7 +5579,7 @@ async def _list_custom_object_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5997,7 +5997,7 @@ async def _list_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6060,7 +6060,7 @@ async def _list_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6413,7 +6413,7 @@ async def _patch_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6454,7 +6454,7 @@ async def _patch_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -6463,7 +6463,7 @@ async def _patch_cluster_custom_object_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6473,7 +6473,7 @@ async def _patch_cluster_custom_object_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6819,7 +6819,7 @@ async def _patch_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6860,7 +6860,7 @@ async def _patch_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6871,7 +6871,7 @@ async def _patch_cluster_custom_object_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6881,7 +6881,7 @@ async def _patch_cluster_custom_object_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7227,7 +7227,7 @@ async def _patch_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7268,7 +7268,7 @@ async def _patch_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7279,7 +7279,7 @@ async def _patch_cluster_custom_object_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7289,7 +7289,7 @@ async def _patch_cluster_custom_object_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7648,7 +7648,7 @@ async def _patch_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7691,7 +7691,7 @@ async def _patch_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -7700,7 +7700,7 @@ async def _patch_namespaced_custom_object_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7710,7 +7710,7 @@ async def _patch_namespaced_custom_object_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8069,7 +8069,7 @@ async def _patch_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8112,7 +8112,7 @@ async def _patch_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8123,7 +8123,7 @@ async def _patch_namespaced_custom_object_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8134,7 +8134,7 @@ async def _patch_namespaced_custom_object_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8493,7 +8493,7 @@ async def _patch_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8536,7 +8536,7 @@ async def _patch_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8547,7 +8547,7 @@ async def _patch_namespaced_custom_object_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8558,7 +8558,7 @@ async def _patch_namespaced_custom_object_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8891,7 +8891,7 @@ async def _replace_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8928,7 +8928,7 @@ async def _replace_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -9270,7 +9270,7 @@ async def _replace_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9307,7 +9307,7 @@ async def _replace_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9651,7 +9651,7 @@ async def _replace_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9688,7 +9688,7 @@ async def _replace_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10042,7 +10042,7 @@ async def _replace_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10081,7 +10081,7 @@ async def _replace_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -10436,7 +10436,7 @@ async def _replace_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10475,7 +10475,7 @@ async def _replace_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10832,7 +10832,7 @@ async def _replace_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10871,7 +10871,7 @@ async def _replace_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/discovery_api.py b/kubernetes/aio/client/api/discovery_api.py index b80c434d04..b0f21b6804 100644 --- a/kubernetes/aio/client/api/discovery_api.py +++ b/kubernetes/aio/client/api/discovery_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/discovery_v1_api.py b/kubernetes/aio/client/api/discovery_v1_api.py index 0c8eb9ef9a..6acfc1241d 100644 --- a/kubernetes/aio/client/api/discovery_v1_api.py +++ b/kubernetes/aio/client/api/discovery_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_endpoint_slice_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_endpoint_slice_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_endpoint_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_endpoint_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3193,7 +3193,7 @@ async def _read_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3216,7 +3216,7 @@ async def _read_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3548,7 +3548,7 @@ async def _replace_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ async def _replace_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/events_api.py b/kubernetes/aio/client/api/events_api.py index 12b7828c1d..838686d419 100644 --- a/kubernetes/aio/client/api/events_api.py +++ b/kubernetes/aio/client/api/events_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/events_v1_api.py b/kubernetes/aio/client/api/events_v1_api.py index b43edd3bc0..8628a9a2cd 100644 --- a/kubernetes/aio/client/api/events_v1_api.py +++ b/kubernetes/aio/client/api/events_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1972,7 +1972,7 @@ async def _list_event_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2035,7 +2035,7 @@ async def _list_event_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ async def _list_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_event_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_event_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3193,7 +3193,7 @@ async def _read_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3216,7 +3216,7 @@ async def _read_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3548,7 +3548,7 @@ async def _replace_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ async def _replace_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/flowcontrol_apiserver_api.py b/kubernetes/aio/client/api/flowcontrol_apiserver_api.py index bcf921bcb8..e435604e72 100644 --- a/kubernetes/aio/client/api/flowcontrol_apiserver_api.py +++ b/kubernetes/aio/client/api/flowcontrol_apiserver_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/flowcontrol_apiserver_v1_api.py b/kubernetes/aio/client/api/flowcontrol_apiserver_v1_api.py index 696886ea65..6c508b622f 100644 --- a/kubernetes/aio/client/api/flowcontrol_apiserver_v1_api.py +++ b/kubernetes/aio/client/api/flowcontrol_apiserver_v1_api.py @@ -338,7 +338,7 @@ async def _create_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -371,7 +371,7 @@ async def _create_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -680,7 +680,7 @@ async def _create_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -713,7 +713,7 @@ async def _create_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1159,7 +1159,7 @@ async def _delete_collection_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1236,7 +1236,7 @@ async def _delete_collection_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1682,7 +1682,7 @@ async def _delete_collection_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1759,7 +1759,7 @@ async def _delete_collection_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2104,7 +2104,7 @@ async def _delete_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2147,7 +2147,7 @@ async def _delete_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2492,7 +2492,7 @@ async def _delete_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2535,7 +2535,7 @@ async def _delete_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2773,7 +2773,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2788,7 +2788,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3182,7 +3182,7 @@ async def _list_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3245,7 +3245,7 @@ async def _list_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3642,7 +3642,7 @@ async def _list_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3705,7 +3705,7 @@ async def _list_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4040,7 +4040,7 @@ async def _patch_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4079,7 +4079,7 @@ async def _patch_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4091,7 +4091,7 @@ async def _patch_flow_schema_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4105,7 +4105,7 @@ async def _patch_flow_schema_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4428,7 +4428,7 @@ async def _patch_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4467,7 +4467,7 @@ async def _patch_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4479,7 +4479,7 @@ async def _patch_flow_schema_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4493,7 +4493,7 @@ async def _patch_flow_schema_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4816,7 +4816,7 @@ async def _patch_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4855,7 +4855,7 @@ async def _patch_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4867,7 +4867,7 @@ async def _patch_priority_level_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4881,7 +4881,7 @@ async def _patch_priority_level_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5204,7 +5204,7 @@ async def _patch_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5243,7 +5243,7 @@ async def _patch_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5255,7 +5255,7 @@ async def _patch_priority_level_configuration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5269,7 +5269,7 @@ async def _patch_priority_level_configuration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5524,7 +5524,7 @@ async def _read_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5545,7 +5545,7 @@ async def _read_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5809,7 +5809,7 @@ async def _read_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5830,7 +5830,7 @@ async def _read_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6094,7 +6094,7 @@ async def _read_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6115,7 +6115,7 @@ async def _read_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6379,7 +6379,7 @@ async def _read_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6400,7 +6400,7 @@ async def _read_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6719,7 +6719,7 @@ async def _replace_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6754,7 +6754,7 @@ async def _replace_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7073,7 +7073,7 @@ async def _replace_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7108,7 +7108,7 @@ async def _replace_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7427,7 +7427,7 @@ async def _replace_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7462,7 +7462,7 @@ async def _replace_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7781,7 +7781,7 @@ async def _replace_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7816,7 +7816,7 @@ async def _replace_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/internal_apiserver_api.py b/kubernetes/aio/client/api/internal_apiserver_api.py index 6fb26eec7a..88b6b61cf4 100644 --- a/kubernetes/aio/client/api/internal_apiserver_api.py +++ b/kubernetes/aio/client/api/internal_apiserver_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/internal_apiserver_v1alpha1_api.py b/kubernetes/aio/client/api/internal_apiserver_v1alpha1_api.py index b4d961acc7..1c38faad06 100644 --- a/kubernetes/aio/client/api/internal_apiserver_v1alpha1_api.py +++ b/kubernetes/aio/client/api/internal_apiserver_v1alpha1_api.py @@ -336,7 +336,7 @@ async def _create_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_storage_version_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_storage_version_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2713,7 +2713,7 @@ async def _patch_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2752,7 +2752,7 @@ async def _patch_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2764,7 +2764,7 @@ async def _patch_storage_version_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2778,7 +2778,7 @@ async def _patch_storage_version_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3033,7 +3033,7 @@ async def _read_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3054,7 +3054,7 @@ async def _read_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3318,7 +3318,7 @@ async def _read_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3339,7 +3339,7 @@ async def _read_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3658,7 +3658,7 @@ async def _replace_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3693,7 +3693,7 @@ async def _replace_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4012,7 +4012,7 @@ async def _replace_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4047,7 +4047,7 @@ async def _replace_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/lifecycle_api.py b/kubernetes/aio/client/api/lifecycle_api.py index c1857cb967..a15425b824 100644 --- a/kubernetes/aio/client/api/lifecycle_api.py +++ b/kubernetes/aio/client/api/lifecycle_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/lifecycle_v1alpha1_api.py b/kubernetes/aio/client/api/lifecycle_v1alpha1_api.py index 957887af26..f8bb4de3b7 100644 --- a/kubernetes/aio/client/api/lifecycle_v1alpha1_api.py +++ b/kubernetes/aio/client/api/lifecycle_v1alpha1_api.py @@ -351,7 +351,7 @@ async def _create_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -386,7 +386,7 @@ async def _create_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -708,7 +708,7 @@ async def _create_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -743,7 +743,7 @@ async def _create_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1202,7 +1202,7 @@ async def _delete_collection_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1281,7 +1281,7 @@ async def _delete_collection_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1740,7 +1740,7 @@ async def _delete_collection_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1819,7 +1819,7 @@ async def _delete_collection_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2177,7 +2177,7 @@ async def _delete_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2222,7 +2222,7 @@ async def _delete_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2580,7 +2580,7 @@ async def _delete_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2625,7 +2625,7 @@ async def _delete_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2863,7 +2863,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2878,7 +2878,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3272,7 +3272,7 @@ async def _list_eviction_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3335,7 +3335,7 @@ async def _list_eviction_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3732,7 +3732,7 @@ async def _list_eviction_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3795,7 +3795,7 @@ async def _list_eviction_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4205,7 +4205,7 @@ async def _list_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4270,7 +4270,7 @@ async def _list_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4680,7 +4680,7 @@ async def _list_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4745,7 +4745,7 @@ async def _list_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5093,7 +5093,7 @@ async def _patch_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5134,7 +5134,7 @@ async def _patch_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5146,7 +5146,7 @@ async def _patch_namespaced_eviction_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5160,7 +5160,7 @@ async def _patch_namespaced_eviction_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5496,7 +5496,7 @@ async def _patch_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5537,7 +5537,7 @@ async def _patch_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5549,7 +5549,7 @@ async def _patch_namespaced_eviction_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5563,7 +5563,7 @@ async def _patch_namespaced_eviction_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5899,7 +5899,7 @@ async def _patch_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5940,7 +5940,7 @@ async def _patch_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5952,7 +5952,7 @@ async def _patch_namespaced_eviction_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5966,7 +5966,7 @@ async def _patch_namespaced_eviction_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6302,7 +6302,7 @@ async def _patch_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6343,7 +6343,7 @@ async def _patch_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6355,7 +6355,7 @@ async def _patch_namespaced_eviction_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6369,7 +6369,7 @@ async def _patch_namespaced_eviction_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6637,7 +6637,7 @@ async def _read_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6660,7 +6660,7 @@ async def _read_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6937,7 +6937,7 @@ async def _read_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6960,7 +6960,7 @@ async def _read_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7237,7 +7237,7 @@ async def _read_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7260,7 +7260,7 @@ async def _read_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7537,7 +7537,7 @@ async def _read_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7560,7 +7560,7 @@ async def _read_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7892,7 +7892,7 @@ async def _replace_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7929,7 +7929,7 @@ async def _replace_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8261,7 +8261,7 @@ async def _replace_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8298,7 +8298,7 @@ async def _replace_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8630,7 +8630,7 @@ async def _replace_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8667,7 +8667,7 @@ async def _replace_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8999,7 +8999,7 @@ async def _replace_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9036,7 +9036,7 @@ async def _replace_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/logs_api.py b/kubernetes/aio/client/api/logs_api.py index 70459edf07..271c71a404 100644 --- a/kubernetes/aio/client/api/logs_api.py +++ b/kubernetes/aio/client/api/logs_api.py @@ -266,7 +266,7 @@ async def _log_file_handler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -505,7 +505,7 @@ async def _log_file_list_handler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] diff --git a/kubernetes/aio/client/api/networking_api.py b/kubernetes/aio/client/api/networking_api.py index 35930bc693..40c32f17b2 100644 --- a/kubernetes/aio/client/api/networking_api.py +++ b/kubernetes/aio/client/api/networking_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/networking_v1_api.py b/kubernetes/aio/client/api/networking_v1_api.py index 230980ef31..e9a7b85cf6 100644 --- a/kubernetes/aio/client/api/networking_v1_api.py +++ b/kubernetes/aio/client/api/networking_v1_api.py @@ -344,7 +344,7 @@ async def _create_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -377,7 +377,7 @@ async def _create_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -686,7 +686,7 @@ async def _create_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -719,7 +719,7 @@ async def _create_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1041,7 +1041,7 @@ async def _create_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1076,7 +1076,7 @@ async def _create_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1398,7 +1398,7 @@ async def _create_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1433,7 +1433,7 @@ async def _create_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1742,7 +1742,7 @@ async def _create_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1775,7 +1775,7 @@ async def _create_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2221,7 +2221,7 @@ async def _delete_collection_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2298,7 +2298,7 @@ async def _delete_collection_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2744,7 +2744,7 @@ async def _delete_collection_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2821,7 +2821,7 @@ async def _delete_collection_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3280,7 +3280,7 @@ async def _delete_collection_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3359,7 +3359,7 @@ async def _delete_collection_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3818,7 +3818,7 @@ async def _delete_collection_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3897,7 +3897,7 @@ async def _delete_collection_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4343,7 +4343,7 @@ async def _delete_collection_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4420,7 +4420,7 @@ async def _delete_collection_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4765,7 +4765,7 @@ async def _delete_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4808,7 +4808,7 @@ async def _delete_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5153,7 +5153,7 @@ async def _delete_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5196,7 +5196,7 @@ async def _delete_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5554,7 +5554,7 @@ async def _delete_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5599,7 +5599,7 @@ async def _delete_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5957,7 +5957,7 @@ async def _delete_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6002,7 +6002,7 @@ async def _delete_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6347,7 +6347,7 @@ async def _delete_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6390,7 +6390,7 @@ async def _delete_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6628,7 +6628,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6643,7 +6643,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7037,7 +7037,7 @@ async def _list_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7100,7 +7100,7 @@ async def _list_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7497,7 +7497,7 @@ async def _list_ingress_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7560,7 +7560,7 @@ async def _list_ingress_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7957,7 +7957,7 @@ async def _list_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8020,7 +8020,7 @@ async def _list_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8430,7 +8430,7 @@ async def _list_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8495,7 +8495,7 @@ async def _list_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8905,7 +8905,7 @@ async def _list_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8970,7 +8970,7 @@ async def _list_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9367,7 +9367,7 @@ async def _list_network_policy_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9430,7 +9430,7 @@ async def _list_network_policy_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9827,7 +9827,7 @@ async def _list_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9890,7 +9890,7 @@ async def _list_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10225,7 +10225,7 @@ async def _patch_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10264,7 +10264,7 @@ async def _patch_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10276,7 +10276,7 @@ async def _patch_ingress_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10290,7 +10290,7 @@ async def _patch_ingress_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10613,7 +10613,7 @@ async def _patch_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10652,7 +10652,7 @@ async def _patch_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10664,7 +10664,7 @@ async def _patch_ip_address_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10678,7 +10678,7 @@ async def _patch_ip_address_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11014,7 +11014,7 @@ async def _patch_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11055,7 +11055,7 @@ async def _patch_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11067,7 +11067,7 @@ async def _patch_namespaced_ingress_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11081,7 +11081,7 @@ async def _patch_namespaced_ingress_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11417,7 +11417,7 @@ async def _patch_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11458,7 +11458,7 @@ async def _patch_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11470,7 +11470,7 @@ async def _patch_namespaced_ingress_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11484,7 +11484,7 @@ async def _patch_namespaced_ingress_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11820,7 +11820,7 @@ async def _patch_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11861,7 +11861,7 @@ async def _patch_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11873,7 +11873,7 @@ async def _patch_namespaced_network_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11887,7 +11887,7 @@ async def _patch_namespaced_network_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12210,7 +12210,7 @@ async def _patch_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12249,7 +12249,7 @@ async def _patch_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ async def _patch_service_cidr_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12275,7 +12275,7 @@ async def _patch_service_cidr_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12598,7 +12598,7 @@ async def _patch_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12637,7 +12637,7 @@ async def _patch_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12649,7 +12649,7 @@ async def _patch_service_cidr_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12663,7 +12663,7 @@ async def _patch_service_cidr_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12918,7 +12918,7 @@ async def _read_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12939,7 +12939,7 @@ async def _read_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13203,7 +13203,7 @@ async def _read_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13224,7 +13224,7 @@ async def _read_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13501,7 +13501,7 @@ async def _read_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13524,7 +13524,7 @@ async def _read_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13801,7 +13801,7 @@ async def _read_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13824,7 +13824,7 @@ async def _read_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14101,7 +14101,7 @@ async def _read_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14124,7 +14124,7 @@ async def _read_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14388,7 +14388,7 @@ async def _read_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14409,7 +14409,7 @@ async def _read_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14673,7 +14673,7 @@ async def _read_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14694,7 +14694,7 @@ async def _read_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15013,7 +15013,7 @@ async def _replace_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15048,7 +15048,7 @@ async def _replace_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15367,7 +15367,7 @@ async def _replace_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15402,7 +15402,7 @@ async def _replace_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15734,7 +15734,7 @@ async def _replace_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15771,7 +15771,7 @@ async def _replace_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16103,7 +16103,7 @@ async def _replace_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16140,7 +16140,7 @@ async def _replace_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16472,7 +16472,7 @@ async def _replace_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16509,7 +16509,7 @@ async def _replace_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16828,7 +16828,7 @@ async def _replace_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16863,7 +16863,7 @@ async def _replace_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17182,7 +17182,7 @@ async def _replace_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17217,7 +17217,7 @@ async def _replace_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/node_api.py b/kubernetes/aio/client/api/node_api.py index 1bdb3d2299..22aef3da66 100644 --- a/kubernetes/aio/client/api/node_api.py +++ b/kubernetes/aio/client/api/node_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/node_v1_api.py b/kubernetes/aio/client/api/node_v1_api.py index 61c429c059..40e351f4f0 100644 --- a/kubernetes/aio/client/api/node_v1_api.py +++ b/kubernetes/aio/client/api/node_v1_api.py @@ -336,7 +336,7 @@ async def _create_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_runtime_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_runtime_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2645,7 +2645,7 @@ async def _read_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2666,7 +2666,7 @@ async def _read_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2985,7 +2985,7 @@ async def _replace_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3020,7 +3020,7 @@ async def _replace_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/openid_api.py b/kubernetes/aio/client/api/openid_api.py index df96bff641..e5e98725f0 100644 --- a/kubernetes/aio/client/api/openid_api.py +++ b/kubernetes/aio/client/api/openid_api.py @@ -258,7 +258,7 @@ async def _get_service_account_issuer_open_id_keyset_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_service_account_issuer_open_id_keyset_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/jwk-set+json' diff --git a/kubernetes/aio/client/api/policy_api.py b/kubernetes/aio/client/api/policy_api.py index 96fe08008b..ec85c6057f 100644 --- a/kubernetes/aio/client/api/policy_api.py +++ b/kubernetes/aio/client/api/policy_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/policy_v1_api.py b/kubernetes/aio/client/api/policy_v1_api.py index 166fe05e63..cd29253bee 100644 --- a/kubernetes/aio/client/api/policy_v1_api.py +++ b/kubernetes/aio/client/api/policy_v1_api.py @@ -349,7 +349,7 @@ async def _create_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -384,7 +384,7 @@ async def _create_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -843,7 +843,7 @@ async def _delete_collection_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -922,7 +922,7 @@ async def _delete_collection_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1280,7 +1280,7 @@ async def _delete_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1325,7 +1325,7 @@ async def _delete_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1563,7 +1563,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1578,7 +1578,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1985,7 +1985,7 @@ async def _list_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2050,7 +2050,7 @@ async def _list_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2447,7 +2447,7 @@ async def _list_pod_disruption_budget_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ async def _list_pod_disruption_budget_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2858,7 +2858,7 @@ async def _patch_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2899,7 +2899,7 @@ async def _patch_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2911,7 +2911,7 @@ async def _patch_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2925,7 +2925,7 @@ async def _patch_namespaced_pod_disruption_budget_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3261,7 +3261,7 @@ async def _patch_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3302,7 +3302,7 @@ async def _patch_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3314,7 +3314,7 @@ async def _patch_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3328,7 +3328,7 @@ async def _patch_namespaced_pod_disruption_budget_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3596,7 +3596,7 @@ async def _read_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3619,7 +3619,7 @@ async def _read_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3896,7 +3896,7 @@ async def _read_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3919,7 +3919,7 @@ async def _read_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4251,7 +4251,7 @@ async def _replace_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4288,7 +4288,7 @@ async def _replace_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4620,7 +4620,7 @@ async def _replace_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4657,7 +4657,7 @@ async def _replace_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/rbac_authorization_api.py b/kubernetes/aio/client/api/rbac_authorization_api.py index 80540d5462..50d4e3a2ab 100644 --- a/kubernetes/aio/client/api/rbac_authorization_api.py +++ b/kubernetes/aio/client/api/rbac_authorization_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/rbac_authorization_v1_api.py b/kubernetes/aio/client/api/rbac_authorization_v1_api.py index 27554d441c..393b941c06 100644 --- a/kubernetes/aio/client/api/rbac_authorization_v1_api.py +++ b/kubernetes/aio/client/api/rbac_authorization_v1_api.py @@ -342,7 +342,7 @@ async def _create_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -375,7 +375,7 @@ async def _create_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -684,7 +684,7 @@ async def _create_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -717,7 +717,7 @@ async def _create_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1039,7 +1039,7 @@ async def _create_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1074,7 +1074,7 @@ async def _create_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1396,7 +1396,7 @@ async def _create_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1431,7 +1431,7 @@ async def _create_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1776,7 +1776,7 @@ async def _delete_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1819,7 +1819,7 @@ async def _delete_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2164,7 +2164,7 @@ async def _delete_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2207,7 +2207,7 @@ async def _delete_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2653,7 +2653,7 @@ async def _delete_collection_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2730,7 +2730,7 @@ async def _delete_collection_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3176,7 +3176,7 @@ async def _delete_collection_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3253,7 +3253,7 @@ async def _delete_collection_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3712,7 +3712,7 @@ async def _delete_collection_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3791,7 +3791,7 @@ async def _delete_collection_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4250,7 +4250,7 @@ async def _delete_collection_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4329,7 +4329,7 @@ async def _delete_collection_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4687,7 +4687,7 @@ async def _delete_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4732,7 +4732,7 @@ async def _delete_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5090,7 +5090,7 @@ async def _delete_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5135,7 +5135,7 @@ async def _delete_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5373,7 +5373,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5388,7 +5388,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5782,7 +5782,7 @@ async def _list_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5845,7 +5845,7 @@ async def _list_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6242,7 +6242,7 @@ async def _list_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6305,7 +6305,7 @@ async def _list_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6715,7 +6715,7 @@ async def _list_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6780,7 +6780,7 @@ async def _list_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7190,7 +7190,7 @@ async def _list_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7255,7 +7255,7 @@ async def _list_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7652,7 +7652,7 @@ async def _list_role_binding_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7715,7 +7715,7 @@ async def _list_role_binding_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8112,7 +8112,7 @@ async def _list_role_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8175,7 +8175,7 @@ async def _list_role_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8510,7 +8510,7 @@ async def _patch_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8549,7 +8549,7 @@ async def _patch_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8561,7 +8561,7 @@ async def _patch_cluster_role_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8575,7 +8575,7 @@ async def _patch_cluster_role_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8898,7 +8898,7 @@ async def _patch_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8937,7 +8937,7 @@ async def _patch_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8949,7 +8949,7 @@ async def _patch_cluster_role_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8963,7 +8963,7 @@ async def _patch_cluster_role_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9299,7 +9299,7 @@ async def _patch_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9340,7 +9340,7 @@ async def _patch_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9352,7 +9352,7 @@ async def _patch_namespaced_role_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9366,7 +9366,7 @@ async def _patch_namespaced_role_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9702,7 +9702,7 @@ async def _patch_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9743,7 +9743,7 @@ async def _patch_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9755,7 +9755,7 @@ async def _patch_namespaced_role_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9769,7 +9769,7 @@ async def _patch_namespaced_role_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10024,7 +10024,7 @@ async def _read_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10045,7 +10045,7 @@ async def _read_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10309,7 +10309,7 @@ async def _read_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10330,7 +10330,7 @@ async def _read_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10607,7 +10607,7 @@ async def _read_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10630,7 +10630,7 @@ async def _read_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10907,7 +10907,7 @@ async def _read_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10930,7 +10930,7 @@ async def _read_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11249,7 +11249,7 @@ async def _replace_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11284,7 +11284,7 @@ async def _replace_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11603,7 +11603,7 @@ async def _replace_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11638,7 +11638,7 @@ async def _replace_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11970,7 +11970,7 @@ async def _replace_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12007,7 +12007,7 @@ async def _replace_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12339,7 +12339,7 @@ async def _replace_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12376,7 +12376,7 @@ async def _replace_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/resource_api.py b/kubernetes/aio/client/api/resource_api.py index 2bb1121adf..af26e87dc6 100644 --- a/kubernetes/aio/client/api/resource_api.py +++ b/kubernetes/aio/client/api/resource_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/resource_v1_api.py b/kubernetes/aio/client/api/resource_v1_api.py index 2972c0070a..3207e33db4 100644 --- a/kubernetes/aio/client/api/resource_v1_api.py +++ b/kubernetes/aio/client/api/resource_v1_api.py @@ -344,7 +344,7 @@ async def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -377,7 +377,7 @@ async def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -686,7 +686,7 @@ async def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -719,7 +719,7 @@ async def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1041,7 +1041,7 @@ async def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1076,7 +1076,7 @@ async def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1398,7 +1398,7 @@ async def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1433,7 +1433,7 @@ async def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1742,7 +1742,7 @@ async def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1775,7 +1775,7 @@ async def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2221,7 +2221,7 @@ async def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2298,7 +2298,7 @@ async def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2744,7 +2744,7 @@ async def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2821,7 +2821,7 @@ async def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3280,7 +3280,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3359,7 +3359,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3818,7 +3818,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3897,7 +3897,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4343,7 +4343,7 @@ async def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4420,7 +4420,7 @@ async def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4765,7 +4765,7 @@ async def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4808,7 +4808,7 @@ async def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5153,7 +5153,7 @@ async def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5196,7 +5196,7 @@ async def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5554,7 +5554,7 @@ async def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5599,7 +5599,7 @@ async def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5957,7 +5957,7 @@ async def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6002,7 +6002,7 @@ async def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6347,7 +6347,7 @@ async def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6390,7 +6390,7 @@ async def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6628,7 +6628,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6643,7 +6643,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7037,7 +7037,7 @@ async def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7100,7 +7100,7 @@ async def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7497,7 +7497,7 @@ async def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7560,7 +7560,7 @@ async def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7970,7 +7970,7 @@ async def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8035,7 +8035,7 @@ async def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8445,7 +8445,7 @@ async def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8510,7 +8510,7 @@ async def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8907,7 +8907,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8970,7 +8970,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9367,7 +9367,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9430,7 +9430,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9827,7 +9827,7 @@ async def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9890,7 +9890,7 @@ async def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10225,7 +10225,7 @@ async def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10264,7 +10264,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10276,7 +10276,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10290,7 +10290,7 @@ async def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10613,7 +10613,7 @@ async def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10652,7 +10652,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10664,7 +10664,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10678,7 +10678,7 @@ async def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11001,7 +11001,7 @@ async def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11040,7 +11040,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11052,7 +11052,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11066,7 +11066,7 @@ async def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11402,7 +11402,7 @@ async def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11443,7 +11443,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11455,7 +11455,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11469,7 +11469,7 @@ async def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11805,7 +11805,7 @@ async def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11846,7 +11846,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11858,7 +11858,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11872,7 +11872,7 @@ async def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12208,7 +12208,7 @@ async def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12249,7 +12249,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12275,7 +12275,7 @@ async def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12598,7 +12598,7 @@ async def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12637,7 +12637,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12649,7 +12649,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12663,7 +12663,7 @@ async def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12918,7 +12918,7 @@ async def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12939,7 +12939,7 @@ async def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13203,7 +13203,7 @@ async def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13224,7 +13224,7 @@ async def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13488,7 +13488,7 @@ async def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13509,7 +13509,7 @@ async def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13786,7 +13786,7 @@ async def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13809,7 +13809,7 @@ async def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14086,7 +14086,7 @@ async def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14109,7 +14109,7 @@ async def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14386,7 +14386,7 @@ async def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14409,7 +14409,7 @@ async def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14673,7 +14673,7 @@ async def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14694,7 +14694,7 @@ async def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15013,7 +15013,7 @@ async def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15048,7 +15048,7 @@ async def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15367,7 +15367,7 @@ async def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15402,7 +15402,7 @@ async def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15721,7 +15721,7 @@ async def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15756,7 +15756,7 @@ async def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16088,7 +16088,7 @@ async def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16125,7 +16125,7 @@ async def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16457,7 +16457,7 @@ async def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16494,7 +16494,7 @@ async def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16826,7 +16826,7 @@ async def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16863,7 +16863,7 @@ async def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17182,7 +17182,7 @@ async def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17217,7 +17217,7 @@ async def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/resource_v1alpha3_api.py b/kubernetes/aio/client/api/resource_v1alpha3_api.py index 5778fa0241..2ec2351b83 100644 --- a/kubernetes/aio/client/api/resource_v1alpha3_api.py +++ b/kubernetes/aio/client/api/resource_v1alpha3_api.py @@ -338,7 +338,7 @@ async def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -371,7 +371,7 @@ async def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -680,7 +680,7 @@ async def _create_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -713,7 +713,7 @@ async def _create_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1159,7 +1159,7 @@ async def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1236,7 +1236,7 @@ async def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1682,7 +1682,7 @@ async def _delete_collection_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1759,7 +1759,7 @@ async def _delete_collection_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2104,7 +2104,7 @@ async def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2147,7 +2147,7 @@ async def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2492,7 +2492,7 @@ async def _delete_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2535,7 +2535,7 @@ async def _delete_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2773,7 +2773,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2788,7 +2788,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3182,7 +3182,7 @@ async def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3245,7 +3245,7 @@ async def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3642,7 +3642,7 @@ async def _list_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3705,7 +3705,7 @@ async def _list_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4040,7 +4040,7 @@ async def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4079,7 +4079,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4091,7 +4091,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4105,7 +4105,7 @@ async def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4428,7 +4428,7 @@ async def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4467,7 +4467,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4479,7 +4479,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4493,7 +4493,7 @@ async def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4816,7 +4816,7 @@ async def _patch_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4855,7 +4855,7 @@ async def _patch_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4867,7 +4867,7 @@ async def _patch_resource_pool_status_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4881,7 +4881,7 @@ async def _patch_resource_pool_status_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5204,7 +5204,7 @@ async def _patch_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5243,7 +5243,7 @@ async def _patch_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5255,7 +5255,7 @@ async def _patch_resource_pool_status_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5269,7 +5269,7 @@ async def _patch_resource_pool_status_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5524,7 +5524,7 @@ async def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5545,7 +5545,7 @@ async def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5809,7 +5809,7 @@ async def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5830,7 +5830,7 @@ async def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6094,7 +6094,7 @@ async def _read_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6115,7 +6115,7 @@ async def _read_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6379,7 +6379,7 @@ async def _read_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6400,7 +6400,7 @@ async def _read_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6719,7 +6719,7 @@ async def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6754,7 +6754,7 @@ async def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7073,7 +7073,7 @@ async def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7108,7 +7108,7 @@ async def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7427,7 +7427,7 @@ async def _replace_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7462,7 +7462,7 @@ async def _replace_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7781,7 +7781,7 @@ async def _replace_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7816,7 +7816,7 @@ async def _replace_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/resource_v1beta1_api.py b/kubernetes/aio/client/api/resource_v1beta1_api.py index d69800aec2..6cede6ea1d 100644 --- a/kubernetes/aio/client/api/resource_v1beta1_api.py +++ b/kubernetes/aio/client/api/resource_v1beta1_api.py @@ -342,7 +342,7 @@ async def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -375,7 +375,7 @@ async def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -697,7 +697,7 @@ async def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -732,7 +732,7 @@ async def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1054,7 +1054,7 @@ async def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1089,7 +1089,7 @@ async def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1398,7 +1398,7 @@ async def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1431,7 +1431,7 @@ async def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1877,7 +1877,7 @@ async def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1954,7 +1954,7 @@ async def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2413,7 +2413,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2492,7 +2492,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2951,7 +2951,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3030,7 +3030,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3476,7 +3476,7 @@ async def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3553,7 +3553,7 @@ async def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3898,7 +3898,7 @@ async def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3941,7 +3941,7 @@ async def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4299,7 +4299,7 @@ async def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4344,7 +4344,7 @@ async def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4702,7 +4702,7 @@ async def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4747,7 +4747,7 @@ async def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5092,7 +5092,7 @@ async def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5135,7 +5135,7 @@ async def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5373,7 +5373,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5388,7 +5388,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5782,7 +5782,7 @@ async def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5845,7 +5845,7 @@ async def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6255,7 +6255,7 @@ async def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6320,7 +6320,7 @@ async def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6730,7 +6730,7 @@ async def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6795,7 +6795,7 @@ async def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7192,7 +7192,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7255,7 +7255,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7652,7 +7652,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7715,7 +7715,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8112,7 +8112,7 @@ async def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8175,7 +8175,7 @@ async def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8510,7 +8510,7 @@ async def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8549,7 +8549,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8561,7 +8561,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8575,7 +8575,7 @@ async def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8911,7 +8911,7 @@ async def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8952,7 +8952,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8964,7 +8964,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8978,7 +8978,7 @@ async def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9314,7 +9314,7 @@ async def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9355,7 +9355,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9367,7 +9367,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9381,7 +9381,7 @@ async def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9717,7 +9717,7 @@ async def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9758,7 +9758,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9770,7 +9770,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9784,7 +9784,7 @@ async def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10107,7 +10107,7 @@ async def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10146,7 +10146,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10158,7 +10158,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10172,7 +10172,7 @@ async def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10427,7 +10427,7 @@ async def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10448,7 +10448,7 @@ async def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10725,7 +10725,7 @@ async def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10748,7 +10748,7 @@ async def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11025,7 +11025,7 @@ async def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11048,7 +11048,7 @@ async def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11325,7 +11325,7 @@ async def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11348,7 +11348,7 @@ async def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11612,7 +11612,7 @@ async def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11633,7 +11633,7 @@ async def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11952,7 +11952,7 @@ async def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11987,7 +11987,7 @@ async def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12319,7 +12319,7 @@ async def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12356,7 +12356,7 @@ async def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12688,7 +12688,7 @@ async def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12725,7 +12725,7 @@ async def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13057,7 +13057,7 @@ async def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13094,7 +13094,7 @@ async def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13413,7 +13413,7 @@ async def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13448,7 +13448,7 @@ async def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/resource_v1beta2_api.py b/kubernetes/aio/client/api/resource_v1beta2_api.py index 5ee6283d72..cc37cdb67b 100644 --- a/kubernetes/aio/client/api/resource_v1beta2_api.py +++ b/kubernetes/aio/client/api/resource_v1beta2_api.py @@ -344,7 +344,7 @@ async def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -377,7 +377,7 @@ async def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -686,7 +686,7 @@ async def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -719,7 +719,7 @@ async def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1041,7 +1041,7 @@ async def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1076,7 +1076,7 @@ async def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1398,7 +1398,7 @@ async def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1433,7 +1433,7 @@ async def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1742,7 +1742,7 @@ async def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1775,7 +1775,7 @@ async def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2221,7 +2221,7 @@ async def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2298,7 +2298,7 @@ async def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2744,7 +2744,7 @@ async def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2821,7 +2821,7 @@ async def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3280,7 +3280,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3359,7 +3359,7 @@ async def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3818,7 +3818,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3897,7 +3897,7 @@ async def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4343,7 +4343,7 @@ async def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4420,7 +4420,7 @@ async def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4765,7 +4765,7 @@ async def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4808,7 +4808,7 @@ async def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5153,7 +5153,7 @@ async def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5196,7 +5196,7 @@ async def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5554,7 +5554,7 @@ async def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5599,7 +5599,7 @@ async def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5957,7 +5957,7 @@ async def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6002,7 +6002,7 @@ async def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6347,7 +6347,7 @@ async def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6390,7 +6390,7 @@ async def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6628,7 +6628,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6643,7 +6643,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7037,7 +7037,7 @@ async def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7100,7 +7100,7 @@ async def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7497,7 +7497,7 @@ async def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7560,7 +7560,7 @@ async def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7970,7 +7970,7 @@ async def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8035,7 +8035,7 @@ async def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8445,7 +8445,7 @@ async def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8510,7 +8510,7 @@ async def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8907,7 +8907,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8970,7 +8970,7 @@ async def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9367,7 +9367,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9430,7 +9430,7 @@ async def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9827,7 +9827,7 @@ async def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9890,7 +9890,7 @@ async def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10225,7 +10225,7 @@ async def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10264,7 +10264,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10276,7 +10276,7 @@ async def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10290,7 +10290,7 @@ async def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10613,7 +10613,7 @@ async def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10652,7 +10652,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10664,7 +10664,7 @@ async def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10678,7 +10678,7 @@ async def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11001,7 +11001,7 @@ async def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11040,7 +11040,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11052,7 +11052,7 @@ async def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11066,7 +11066,7 @@ async def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11402,7 +11402,7 @@ async def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11443,7 +11443,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11455,7 +11455,7 @@ async def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11469,7 +11469,7 @@ async def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11805,7 +11805,7 @@ async def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11846,7 +11846,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11858,7 +11858,7 @@ async def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11872,7 +11872,7 @@ async def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12208,7 +12208,7 @@ async def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12249,7 +12249,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ async def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12275,7 +12275,7 @@ async def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12598,7 +12598,7 @@ async def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12637,7 +12637,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12649,7 +12649,7 @@ async def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12663,7 +12663,7 @@ async def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12918,7 +12918,7 @@ async def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12939,7 +12939,7 @@ async def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13203,7 +13203,7 @@ async def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13224,7 +13224,7 @@ async def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13488,7 +13488,7 @@ async def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13509,7 +13509,7 @@ async def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13786,7 +13786,7 @@ async def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13809,7 +13809,7 @@ async def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14086,7 +14086,7 @@ async def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14109,7 +14109,7 @@ async def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14386,7 +14386,7 @@ async def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14409,7 +14409,7 @@ async def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14673,7 +14673,7 @@ async def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14694,7 +14694,7 @@ async def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15013,7 +15013,7 @@ async def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15048,7 +15048,7 @@ async def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15367,7 +15367,7 @@ async def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15402,7 +15402,7 @@ async def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15721,7 +15721,7 @@ async def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15756,7 +15756,7 @@ async def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16088,7 +16088,7 @@ async def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16125,7 +16125,7 @@ async def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16457,7 +16457,7 @@ async def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16494,7 +16494,7 @@ async def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16826,7 +16826,7 @@ async def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16863,7 +16863,7 @@ async def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17182,7 +17182,7 @@ async def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17217,7 +17217,7 @@ async def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/scheduling_api.py b/kubernetes/aio/client/api/scheduling_api.py index 67b9d31709..44209f65c0 100644 --- a/kubernetes/aio/client/api/scheduling_api.py +++ b/kubernetes/aio/client/api/scheduling_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/scheduling_v1_api.py b/kubernetes/aio/client/api/scheduling_v1_api.py index 523b5e1146..1fa4e08758 100644 --- a/kubernetes/aio/client/api/scheduling_v1_api.py +++ b/kubernetes/aio/client/api/scheduling_v1_api.py @@ -336,7 +336,7 @@ async def _create_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_priority_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_priority_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2645,7 +2645,7 @@ async def _read_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2666,7 +2666,7 @@ async def _read_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2985,7 +2985,7 @@ async def _replace_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3020,7 +3020,7 @@ async def _replace_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/scheduling_v1alpha3_api.py b/kubernetes/aio/client/api/scheduling_v1alpha3_api.py index 4e3823b0b5..900b54c278 100644 --- a/kubernetes/aio/client/api/scheduling_v1alpha3_api.py +++ b/kubernetes/aio/client/api/scheduling_v1alpha3_api.py @@ -353,7 +353,7 @@ async def _create_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -388,7 +388,7 @@ async def _create_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -710,7 +710,7 @@ async def _create_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -745,7 +745,7 @@ async def _create_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1067,7 +1067,7 @@ async def _create_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1102,7 +1102,7 @@ async def _create_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1561,7 +1561,7 @@ async def _delete_collection_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1640,7 +1640,7 @@ async def _delete_collection_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2099,7 +2099,7 @@ async def _delete_collection_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2178,7 +2178,7 @@ async def _delete_collection_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2637,7 +2637,7 @@ async def _delete_collection_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2716,7 +2716,7 @@ async def _delete_collection_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3074,7 +3074,7 @@ async def _delete_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3119,7 +3119,7 @@ async def _delete_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3477,7 +3477,7 @@ async def _delete_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3522,7 +3522,7 @@ async def _delete_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3880,7 +3880,7 @@ async def _delete_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3925,7 +3925,7 @@ async def _delete_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4163,7 +4163,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4178,7 +4178,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4572,7 +4572,7 @@ async def _list_composite_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4635,7 +4635,7 @@ async def _list_composite_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5045,7 +5045,7 @@ async def _list_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5110,7 +5110,7 @@ async def _list_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5520,7 +5520,7 @@ async def _list_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5585,7 +5585,7 @@ async def _list_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5995,7 +5995,7 @@ async def _list_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6060,7 +6060,7 @@ async def _list_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6457,7 +6457,7 @@ async def _list_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6520,7 +6520,7 @@ async def _list_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6917,7 +6917,7 @@ async def _list_workload_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6980,7 +6980,7 @@ async def _list_workload_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7328,7 +7328,7 @@ async def _patch_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7369,7 +7369,7 @@ async def _patch_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7381,7 +7381,7 @@ async def _patch_namespaced_composite_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7395,7 +7395,7 @@ async def _patch_namespaced_composite_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7731,7 +7731,7 @@ async def _patch_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7772,7 +7772,7 @@ async def _patch_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7784,7 +7784,7 @@ async def _patch_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7798,7 +7798,7 @@ async def _patch_namespaced_composite_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8134,7 +8134,7 @@ async def _patch_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8175,7 +8175,7 @@ async def _patch_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8187,7 +8187,7 @@ async def _patch_namespaced_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8201,7 +8201,7 @@ async def _patch_namespaced_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8537,7 +8537,7 @@ async def _patch_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8578,7 +8578,7 @@ async def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8590,7 +8590,7 @@ async def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8604,7 +8604,7 @@ async def _patch_namespaced_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8940,7 +8940,7 @@ async def _patch_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8981,7 +8981,7 @@ async def _patch_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8993,7 +8993,7 @@ async def _patch_namespaced_workload_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9007,7 +9007,7 @@ async def _patch_namespaced_workload_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9275,7 +9275,7 @@ async def _read_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9298,7 +9298,7 @@ async def _read_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9575,7 +9575,7 @@ async def _read_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9598,7 +9598,7 @@ async def _read_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9875,7 +9875,7 @@ async def _read_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9898,7 +9898,7 @@ async def _read_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10175,7 +10175,7 @@ async def _read_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10198,7 +10198,7 @@ async def _read_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10475,7 +10475,7 @@ async def _read_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10498,7 +10498,7 @@ async def _read_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10830,7 +10830,7 @@ async def _replace_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10867,7 +10867,7 @@ async def _replace_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11199,7 +11199,7 @@ async def _replace_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11236,7 +11236,7 @@ async def _replace_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11568,7 +11568,7 @@ async def _replace_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11605,7 +11605,7 @@ async def _replace_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11937,7 +11937,7 @@ async def _replace_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11974,7 +11974,7 @@ async def _replace_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12306,7 +12306,7 @@ async def _replace_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12343,7 +12343,7 @@ async def _replace_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/scheduling_v1beta1_api.py b/kubernetes/aio/client/api/scheduling_v1beta1_api.py index 71e748a274..29417eaad0 100644 --- a/kubernetes/aio/client/api/scheduling_v1beta1_api.py +++ b/kubernetes/aio/client/api/scheduling_v1beta1_api.py @@ -351,7 +351,7 @@ async def _create_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -386,7 +386,7 @@ async def _create_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -708,7 +708,7 @@ async def _create_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -743,7 +743,7 @@ async def _create_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1202,7 +1202,7 @@ async def _delete_collection_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1281,7 +1281,7 @@ async def _delete_collection_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1740,7 +1740,7 @@ async def _delete_collection_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1819,7 +1819,7 @@ async def _delete_collection_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2177,7 +2177,7 @@ async def _delete_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2222,7 +2222,7 @@ async def _delete_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2580,7 +2580,7 @@ async def _delete_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2625,7 +2625,7 @@ async def _delete_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2863,7 +2863,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2878,7 +2878,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3285,7 +3285,7 @@ async def _list_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3350,7 +3350,7 @@ async def _list_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3760,7 +3760,7 @@ async def _list_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3825,7 +3825,7 @@ async def _list_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4222,7 +4222,7 @@ async def _list_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4285,7 +4285,7 @@ async def _list_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4682,7 +4682,7 @@ async def _list_workload_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4745,7 +4745,7 @@ async def _list_workload_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5093,7 +5093,7 @@ async def _patch_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5134,7 +5134,7 @@ async def _patch_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5146,7 +5146,7 @@ async def _patch_namespaced_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5160,7 +5160,7 @@ async def _patch_namespaced_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5496,7 +5496,7 @@ async def _patch_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5537,7 +5537,7 @@ async def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5549,7 +5549,7 @@ async def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5563,7 +5563,7 @@ async def _patch_namespaced_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5899,7 +5899,7 @@ async def _patch_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5940,7 +5940,7 @@ async def _patch_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5952,7 +5952,7 @@ async def _patch_namespaced_workload_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5966,7 +5966,7 @@ async def _patch_namespaced_workload_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6234,7 +6234,7 @@ async def _read_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6257,7 +6257,7 @@ async def _read_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6534,7 +6534,7 @@ async def _read_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6557,7 +6557,7 @@ async def _read_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6834,7 +6834,7 @@ async def _read_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6857,7 +6857,7 @@ async def _read_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7189,7 +7189,7 @@ async def _replace_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7226,7 +7226,7 @@ async def _replace_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7558,7 +7558,7 @@ async def _replace_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7595,7 +7595,7 @@ async def _replace_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7927,7 +7927,7 @@ async def _replace_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7964,7 +7964,7 @@ async def _replace_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/storage_api.py b/kubernetes/aio/client/api/storage_api.py index fabfec0960..cbe70e25fc 100644 --- a/kubernetes/aio/client/api/storage_api.py +++ b/kubernetes/aio/client/api/storage_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/storage_v1_api.py b/kubernetes/aio/client/api/storage_v1_api.py index 445cc29453..01f89ca5f7 100644 --- a/kubernetes/aio/client/api/storage_v1_api.py +++ b/kubernetes/aio/client/api/storage_v1_api.py @@ -346,7 +346,7 @@ async def _create_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -379,7 +379,7 @@ async def _create_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -688,7 +688,7 @@ async def _create_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -721,7 +721,7 @@ async def _create_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1043,7 +1043,7 @@ async def _create_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ async def _create_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1387,7 +1387,7 @@ async def _create_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1420,7 +1420,7 @@ async def _create_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1729,7 +1729,7 @@ async def _create_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1762,7 +1762,7 @@ async def _create_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2071,7 +2071,7 @@ async def _create_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2104,7 +2104,7 @@ async def _create_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2550,7 +2550,7 @@ async def _delete_collection_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2627,7 +2627,7 @@ async def _delete_collection_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3073,7 +3073,7 @@ async def _delete_collection_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3150,7 +3150,7 @@ async def _delete_collection_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3609,7 +3609,7 @@ async def _delete_collection_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3688,7 +3688,7 @@ async def _delete_collection_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4134,7 +4134,7 @@ async def _delete_collection_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4211,7 +4211,7 @@ async def _delete_collection_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4657,7 +4657,7 @@ async def _delete_collection_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4734,7 +4734,7 @@ async def _delete_collection_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5180,7 +5180,7 @@ async def _delete_collection_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5257,7 +5257,7 @@ async def _delete_collection_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5602,7 +5602,7 @@ async def _delete_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5645,7 +5645,7 @@ async def _delete_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5990,7 +5990,7 @@ async def _delete_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6033,7 +6033,7 @@ async def _delete_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6391,7 +6391,7 @@ async def _delete_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6436,7 +6436,7 @@ async def _delete_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6781,7 +6781,7 @@ async def _delete_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6824,7 +6824,7 @@ async def _delete_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7169,7 +7169,7 @@ async def _delete_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7212,7 +7212,7 @@ async def _delete_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7557,7 +7557,7 @@ async def _delete_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7600,7 +7600,7 @@ async def _delete_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7838,7 +7838,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7853,7 +7853,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8247,7 +8247,7 @@ async def _list_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8310,7 +8310,7 @@ async def _list_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8707,7 +8707,7 @@ async def _list_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8770,7 +8770,7 @@ async def _list_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9167,7 +9167,7 @@ async def _list_csi_storage_capacity_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9230,7 +9230,7 @@ async def _list_csi_storage_capacity_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9640,7 +9640,7 @@ async def _list_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9705,7 +9705,7 @@ async def _list_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10102,7 +10102,7 @@ async def _list_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10165,7 +10165,7 @@ async def _list_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10562,7 +10562,7 @@ async def _list_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10625,7 +10625,7 @@ async def _list_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11022,7 +11022,7 @@ async def _list_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11085,7 +11085,7 @@ async def _list_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11420,7 +11420,7 @@ async def _patch_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11459,7 +11459,7 @@ async def _patch_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11471,7 +11471,7 @@ async def _patch_csi_driver_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11485,7 +11485,7 @@ async def _patch_csi_driver_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11808,7 +11808,7 @@ async def _patch_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11847,7 +11847,7 @@ async def _patch_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11859,7 +11859,7 @@ async def _patch_csi_node_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11873,7 +11873,7 @@ async def _patch_csi_node_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12196,7 +12196,7 @@ async def _patch_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12235,7 +12235,7 @@ async def _patch_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12247,7 +12247,7 @@ async def _patch_csi_node_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12261,7 +12261,7 @@ async def _patch_csi_node_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12597,7 +12597,7 @@ async def _patch_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12638,7 +12638,7 @@ async def _patch_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12650,7 +12650,7 @@ async def _patch_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12664,7 +12664,7 @@ async def _patch_namespaced_csi_storage_capacity_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12987,7 +12987,7 @@ async def _patch_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13026,7 +13026,7 @@ async def _patch_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13038,7 +13038,7 @@ async def _patch_storage_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13052,7 +13052,7 @@ async def _patch_storage_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13375,7 +13375,7 @@ async def _patch_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13414,7 +13414,7 @@ async def _patch_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13426,7 +13426,7 @@ async def _patch_volume_attachment_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13440,7 +13440,7 @@ async def _patch_volume_attachment_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13763,7 +13763,7 @@ async def _patch_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13802,7 +13802,7 @@ async def _patch_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13814,7 +13814,7 @@ async def _patch_volume_attachment_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13828,7 +13828,7 @@ async def _patch_volume_attachment_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -14151,7 +14151,7 @@ async def _patch_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14190,7 +14190,7 @@ async def _patch_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14202,7 +14202,7 @@ async def _patch_volume_attributes_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -14216,7 +14216,7 @@ async def _patch_volume_attributes_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -14471,7 +14471,7 @@ async def _read_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14492,7 +14492,7 @@ async def _read_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14756,7 +14756,7 @@ async def _read_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14777,7 +14777,7 @@ async def _read_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15041,7 +15041,7 @@ async def _read_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15062,7 +15062,7 @@ async def _read_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15339,7 +15339,7 @@ async def _read_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15362,7 +15362,7 @@ async def _read_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15626,7 +15626,7 @@ async def _read_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15647,7 +15647,7 @@ async def _read_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15911,7 +15911,7 @@ async def _read_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15932,7 +15932,7 @@ async def _read_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16196,7 +16196,7 @@ async def _read_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16217,7 +16217,7 @@ async def _read_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16481,7 +16481,7 @@ async def _read_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16502,7 +16502,7 @@ async def _read_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16821,7 +16821,7 @@ async def _replace_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16856,7 +16856,7 @@ async def _replace_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17175,7 +17175,7 @@ async def _replace_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17210,7 +17210,7 @@ async def _replace_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17529,7 +17529,7 @@ async def _replace_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17564,7 +17564,7 @@ async def _replace_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17896,7 +17896,7 @@ async def _replace_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17933,7 +17933,7 @@ async def _replace_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18252,7 +18252,7 @@ async def _replace_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18287,7 +18287,7 @@ async def _replace_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18606,7 +18606,7 @@ async def _replace_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18641,7 +18641,7 @@ async def _replace_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18960,7 +18960,7 @@ async def _replace_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18995,7 +18995,7 @@ async def _replace_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19314,7 +19314,7 @@ async def _replace_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19349,7 +19349,7 @@ async def _replace_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/storagemigration_api.py b/kubernetes/aio/client/api/storagemigration_api.py index dd5155b9a8..1617efd798 100644 --- a/kubernetes/aio/client/api/storagemigration_api.py +++ b/kubernetes/aio/client/api/storagemigration_api.py @@ -258,7 +258,7 @@ async def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/storagemigration_v1_api.py b/kubernetes/aio/client/api/storagemigration_v1_api.py index d2371d203e..df869c32d9 100644 --- a/kubernetes/aio/client/api/storagemigration_v1_api.py +++ b/kubernetes/aio/client/api/storagemigration_v1_api.py @@ -336,7 +336,7 @@ async def _create_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_storage_version_migration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_storage_version_migration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2713,7 +2713,7 @@ async def _patch_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2752,7 +2752,7 @@ async def _patch_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2764,7 +2764,7 @@ async def _patch_storage_version_migration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2778,7 +2778,7 @@ async def _patch_storage_version_migration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3033,7 +3033,7 @@ async def _read_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3054,7 +3054,7 @@ async def _read_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3318,7 +3318,7 @@ async def _read_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3339,7 +3339,7 @@ async def _read_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3658,7 +3658,7 @@ async def _replace_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3693,7 +3693,7 @@ async def _replace_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4012,7 +4012,7 @@ async def _replace_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4047,7 +4047,7 @@ async def _replace_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/storagemigration_v1beta1_api.py b/kubernetes/aio/client/api/storagemigration_v1beta1_api.py index 364a9ef281..5920c3aa8f 100644 --- a/kubernetes/aio/client/api/storagemigration_v1beta1_api.py +++ b/kubernetes/aio/client/api/storagemigration_v1beta1_api.py @@ -336,7 +336,7 @@ async def _create_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -369,7 +369,7 @@ async def _create_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -815,7 +815,7 @@ async def _delete_collection_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ async def _delete_collection_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1237,7 +1237,7 @@ async def _delete_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1280,7 +1280,7 @@ async def _delete_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1518,7 +1518,7 @@ async def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1533,7 +1533,7 @@ async def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1927,7 +1927,7 @@ async def _list_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ async def _list_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2325,7 +2325,7 @@ async def _patch_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2364,7 +2364,7 @@ async def _patch_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2376,7 +2376,7 @@ async def _patch_storage_version_migration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2390,7 +2390,7 @@ async def _patch_storage_version_migration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2713,7 +2713,7 @@ async def _patch_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2752,7 +2752,7 @@ async def _patch_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2764,7 +2764,7 @@ async def _patch_storage_version_migration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2778,7 +2778,7 @@ async def _patch_storage_version_migration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3033,7 +3033,7 @@ async def _read_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3054,7 +3054,7 @@ async def _read_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3318,7 +3318,7 @@ async def _read_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3339,7 +3339,7 @@ async def _read_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3658,7 +3658,7 @@ async def _replace_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3693,7 +3693,7 @@ async def _replace_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4012,7 +4012,7 @@ async def _replace_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4047,7 +4047,7 @@ async def _replace_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/aio/client/api/version_api.py b/kubernetes/aio/client/api/version_api.py index 9025b1dee6..c1faa24904 100644 --- a/kubernetes/aio/client/api/version_api.py +++ b/kubernetes/aio/client/api/version_api.py @@ -258,7 +258,7 @@ async def _get_code_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_code_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' diff --git a/kubernetes/aio/client/api/well_known_api.py b/kubernetes/aio/client/api/well_known_api.py index 85e34b697a..451d0badda 100644 --- a/kubernetes/aio/client/api/well_known_api.py +++ b/kubernetes/aio/client/api/well_known_api.py @@ -258,7 +258,7 @@ async def _get_service_account_issuer_open_id_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -273,7 +273,7 @@ async def _get_service_account_issuer_open_id_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' diff --git a/kubernetes/aio/client/api_client.py b/kubernetes/aio/client/api_client.py index 3595abd6bb..dbe1a0a1ef 100644 --- a/kubernetes/aio/client/api_client.py +++ b/kubernetes/aio/client/api_client.py @@ -23,7 +23,7 @@ import uuid from urllib.parse import quote -from typing import Tuple, Optional, List, Dict, Union, Any +from typing import Any, Tuple, Optional, List, Dict, Union from pydantic import SecretStr from kubernetes.aio.client.configuration import Configuration @@ -41,34 +41,7 @@ ) -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict +from kubernetes.aio.client._legacy_model_helpers import _get_openapi_to_dict RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] @@ -137,15 +110,35 @@ async def close(self): @property def user_agent(self): """User agent for this API client""" - return self.default_headers['User-Agent'] + for name, value in reversed(self.default_headers.items()): + if name.lower() == 'user-agent': + return value + raise KeyError('User-Agent') @user_agent.setter def user_agent(self, value): - self.default_headers['User-Agent'] = value + self._set_header(self.default_headers, 'User-Agent', value) def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value + self._set_header(self.default_headers, header_name, header_value) + + @staticmethod + def _set_header(headers: Dict[str, Any], name: str, value: Any) -> None: + """Replace a header case-insensitively, retaining the winning spelling.""" + for key in list(headers): + if key.lower() == name.lower(): + del headers[key] + headers[name] = value + + @classmethod + def _merge_headers(cls, *sources: Optional[Dict[str, Any]]) -> Dict[str, Any]: + """Copy headers; later sources and later entries in each dict win.""" + headers: Dict[str, Any] = {} + for source in sources: + for name, value in (source or {}).items(): + cls._set_header(headers, name, value) + return headers _default = None @@ -210,10 +203,9 @@ async def param_serialize( config = self.configuration # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) + header_params = self._merge_headers(header_params, self.default_headers) if self.cookie: - header_params['Cookie'] = self.cookie + self._set_header(header_params, 'Cookie', self.cookie) if header_params: header_params = self.sanitize_for_serialization(header_params) header_params = dict( @@ -555,6 +547,13 @@ def parameters_to_tuples(self, params, collection_formats): new_params.append((k, v)) return new_params + def explode_query_object(self, name, obj): + """form style, explode: one query parameter per entry, keyed by the property name; a list repeats the name, None is left out""" + obj = self.sanitize_for_serialization(obj) + if not isinstance(obj, dict): + obj = {name: obj} + return [(k, item) for k, v in obj.items() for item in (v if isinstance(v, (list, tuple)) else [v]) if item is not None] + def parameters_to_url_query(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -573,11 +572,12 @@ def parameters_to_url_query(self, params, collection_formats): if isinstance(v, dict): v = json.dumps(v) - if k in collection_formats: + # a collection format applies only to a list; an exploded entry may share a declared array parameter's name + if k in collection_formats and isinstance(v, (list, tuple)): collection_format = collection_formats[k] if collection_format == 'multi': new_params.extend( - (k, quote(str(value).lower() if isinstance(value, bool) else str(value))) + (quote(str(k)), quote(str(value).lower() if isinstance(value, bool) else str(value))) for value in v ) else: @@ -590,12 +590,13 @@ def parameters_to_url_query(self, params, collection_formats): else: # csv is the default delimiter = ',' new_params.append( - (k, delimiter.join( + (quote(str(k)), delimiter.join( quote(str(value).lower() if isinstance(value, bool) else str(value)) for value in v)) ) else: - new_params.append((k, quote(str(v)))) + # names are quoted too: an exploded object's names are runtime data + new_params.append((quote(str(k)), quote(str(v)))) return "&".join(["=".join(map(str, item)) for item in new_params]) @@ -731,7 +732,11 @@ def _apply_auth_params( :param auth_setting: auth settings for the endpoint """ if auth_setting['in'] == 'cookie': - if not 'Cookie' in headers: + for key in list(headers): + if key.lower() == 'cookie': + self._set_header(headers, 'Cookie', headers[key]) + break + if not headers.get('Cookie'): headers['Cookie'] = "" else: headers['Cookie'] += "; " @@ -740,7 +745,7 @@ def _apply_auth_params( headers['Cookie'] += f"{auth_setting['key']}={cookie_value}" elif auth_setting['in'] == 'header': if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] + self._set_header(headers, auth_setting['key'], auth_setting['value']) elif auth_setting['in'] == 'query': queries.append((auth_setting['key'], auth_setting['value'])) else: diff --git a/kubernetes/aio/client/models/admissionregistration_v1_service_reference.py b/kubernetes/aio/client/models/admissionregistration_v1_service_reference.py index 4b30f06016..bc13a08cd4 100644 --- a/kubernetes/aio/client/models/admissionregistration_v1_service_reference.py +++ b/kubernetes/aio/client/models/admissionregistration_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AdmissionregistrationV1ServiceReference(BaseModel): diff --git a/kubernetes/aio/client/models/admissionregistration_v1_webhook_client_config.py b/kubernetes/aio/client/models/admissionregistration_v1_webhook_client_config.py index cd2fa06a77..628baf28e8 100644 --- a/kubernetes/aio/client/models/admissionregistration_v1_webhook_client_config.py +++ b/kubernetes/aio/client/models/admissionregistration_v1_webhook_client_config.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AdmissionregistrationV1WebhookClientConfig(BaseModel): diff --git a/kubernetes/aio/client/models/apiextensions_v1_service_reference.py b/kubernetes/aio/client/models/apiextensions_v1_service_reference.py index 3cc2a02744..d85fda6f19 100644 --- a/kubernetes/aio/client/models/apiextensions_v1_service_reference.py +++ b/kubernetes/aio/client/models/apiextensions_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiextensionsV1ServiceReference(BaseModel): diff --git a/kubernetes/aio/client/models/apiextensions_v1_webhook_client_config.py b/kubernetes/aio/client/models/apiextensions_v1_webhook_client_config.py index 6ab1f1c726..2373ab3cbc 100644 --- a/kubernetes/aio/client/models/apiextensions_v1_webhook_client_config.py +++ b/kubernetes/aio/client/models/apiextensions_v1_webhook_client_config.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiextensionsV1WebhookClientConfig(BaseModel): diff --git a/kubernetes/aio/client/models/apiregistration_v1_service_reference.py b/kubernetes/aio/client/models/apiregistration_v1_service_reference.py index 79c245b8d2..8775b6b19c 100644 --- a/kubernetes/aio/client/models/apiregistration_v1_service_reference.py +++ b/kubernetes/aio/client/models/apiregistration_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiregistrationV1ServiceReference(BaseModel): diff --git a/kubernetes/aio/client/models/authentication_v1_token_request.py b/kubernetes/aio/client/models/authentication_v1_token_request.py index b1b355ddc4..2ebed69831 100644 --- a/kubernetes/aio/client/models/authentication_v1_token_request.py +++ b/kubernetes/aio/client/models/authentication_v1_token_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AuthenticationV1TokenRequest(BaseModel): diff --git a/kubernetes/aio/client/models/core_v1_endpoint_port.py b/kubernetes/aio/client/models/core_v1_endpoint_port.py index ae46003e98..7961279688 100644 --- a/kubernetes/aio/client/models/core_v1_endpoint_port.py +++ b/kubernetes/aio/client/models/core_v1_endpoint_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EndpointPort(BaseModel): diff --git a/kubernetes/aio/client/models/core_v1_event.py b/kubernetes/aio/client/models/core_v1_event.py index be9898553a..2ab856c83c 100644 --- a/kubernetes/aio/client/models/core_v1_event.py +++ b/kubernetes/aio/client/models/core_v1_event.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1Event(BaseModel): diff --git a/kubernetes/aio/client/models/core_v1_event_list.py b/kubernetes/aio/client/models/core_v1_event_list.py index 753fad6e39..d12787f2b9 100644 --- a/kubernetes/aio/client/models/core_v1_event_list.py +++ b/kubernetes/aio/client/models/core_v1_event_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EventList(BaseModel): diff --git a/kubernetes/aio/client/models/core_v1_event_series.py b/kubernetes/aio/client/models/core_v1_event_series.py index 1ecb329601..6c7fc207bc 100644 --- a/kubernetes/aio/client/models/core_v1_event_series.py +++ b/kubernetes/aio/client/models/core_v1_event_series.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EventSeries(BaseModel): diff --git a/kubernetes/aio/client/models/core_v1_resource_claim.py b/kubernetes/aio/client/models/core_v1_resource_claim.py index a8e4da433a..b0872a7d66 100644 --- a/kubernetes/aio/client/models/core_v1_resource_claim.py +++ b/kubernetes/aio/client/models/core_v1_resource_claim.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1ResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/discovery_v1_endpoint_port.py b/kubernetes/aio/client/models/discovery_v1_endpoint_port.py index 3e0d5c1289..360ca61f80 100644 --- a/kubernetes/aio/client/models/discovery_v1_endpoint_port.py +++ b/kubernetes/aio/client/models/discovery_v1_endpoint_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class DiscoveryV1EndpointPort(BaseModel): diff --git a/kubernetes/aio/client/models/events_v1_event.py b/kubernetes/aio/client/models/events_v1_event.py index 9376de653e..c33884319e 100644 --- a/kubernetes/aio/client/models/events_v1_event.py +++ b/kubernetes/aio/client/models/events_v1_event.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1Event(BaseModel): diff --git a/kubernetes/aio/client/models/events_v1_event_list.py b/kubernetes/aio/client/models/events_v1_event_list.py index 984c07aca6..f35e4dba8b 100644 --- a/kubernetes/aio/client/models/events_v1_event_list.py +++ b/kubernetes/aio/client/models/events_v1_event_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1EventList(BaseModel): diff --git a/kubernetes/aio/client/models/events_v1_event_series.py b/kubernetes/aio/client/models/events_v1_event_series.py index 9729193dae..5fd8056bc5 100644 --- a/kubernetes/aio/client/models/events_v1_event_series.py +++ b/kubernetes/aio/client/models/events_v1_event_series.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1EventSeries(BaseModel): diff --git a/kubernetes/aio/client/models/flowcontrol_v1_subject.py b/kubernetes/aio/client/models/flowcontrol_v1_subject.py index bdd0800b05..09350ecafc 100644 --- a/kubernetes/aio/client/models/flowcontrol_v1_subject.py +++ b/kubernetes/aio/client/models/flowcontrol_v1_subject.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class FlowcontrolV1Subject(BaseModel): diff --git a/kubernetes/aio/client/models/rbac_v1_subject.py b/kubernetes/aio/client/models/rbac_v1_subject.py index 8d8b926534..e4c728d866 100644 --- a/kubernetes/aio/client/models/rbac_v1_subject.py +++ b/kubernetes/aio/client/models/rbac_v1_subject.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class RbacV1Subject(BaseModel): diff --git a/kubernetes/aio/client/models/resource_v1_resource_claim.py b/kubernetes/aio/client/models/resource_v1_resource_claim.py index 711e4fffd7..480c4dd661 100644 --- a/kubernetes/aio/client/models/resource_v1_resource_claim.py +++ b/kubernetes/aio/client/models/resource_v1_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ResourceV1ResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/storage_v1_token_request.py b/kubernetes/aio/client/models/storage_v1_token_request.py index 52ba475d18..3fed6794db 100644 --- a/kubernetes/aio/client/models/storage_v1_token_request.py +++ b/kubernetes/aio/client/models/storage_v1_token_request.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class StorageV1TokenRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_affinity.py b/kubernetes/aio/client/models/v1_affinity.py index 420ca3c0be..e842cc2a34 100644 --- a/kubernetes/aio/client/models/v1_affinity.py +++ b/kubernetes/aio/client/models/v1_affinity.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Affinity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_aggregation_rule.py b/kubernetes/aio/client/models/v1_aggregation_rule.py index 7373a6dc21..5a29cab591 100644 --- a/kubernetes/aio/client/models/v1_aggregation_rule.py +++ b/kubernetes/aio/client/models/v1_aggregation_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AggregationRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_allocated_device_status.py b/kubernetes/aio/client/models/v1_allocated_device_status.py index 6dd662d13f..aa435135c3 100644 --- a/kubernetes/aio/client/models/v1_allocated_device_status.py +++ b/kubernetes/aio/client/models/v1_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_allocation_result.py b/kubernetes/aio/client/models/v1_allocation_result.py index c679a894a8..f9b74bb88b 100644 --- a/kubernetes/aio/client/models/v1_allocation_result.py +++ b/kubernetes/aio/client/models/v1_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_group.py b/kubernetes/aio/client/models/v1_api_group.py index d8cfd0eb23..8ea87514bc 100644 --- a/kubernetes/aio/client/models/v1_api_group.py +++ b/kubernetes/aio/client/models/v1_api_group.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIGroup(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_group_list.py b/kubernetes/aio/client/models/v1_api_group_list.py index 12874da5e0..c91e8401ec 100644 --- a/kubernetes/aio/client/models/v1_api_group_list.py +++ b/kubernetes/aio/client/models/v1_api_group_list.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIGroupList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_resource.py b/kubernetes/aio/client/models/v1_api_resource.py index b6ef4cb5f8..aeb094cec1 100644 --- a/kubernetes/aio/client/models/v1_api_resource.py +++ b/kubernetes/aio/client/models/v1_api_resource.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIResource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_resource_list.py b/kubernetes/aio/client/models/v1_api_resource_list.py index a99c4d11b9..22480ec76b 100644 --- a/kubernetes/aio/client/models/v1_api_resource_list.py +++ b/kubernetes/aio/client/models/v1_api_resource_list.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIResourceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_service.py b/kubernetes/aio/client/models/v1_api_service.py index 66a1e71e8e..8cbb2df7c6 100644 --- a/kubernetes/aio/client/models/v1_api_service.py +++ b/kubernetes/aio/client/models/v1_api_service.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIService(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_service_condition.py b/kubernetes/aio/client/models/v1_api_service_condition.py index 9169194fca..8ffa9208b0 100644 --- a/kubernetes/aio/client/models/v1_api_service_condition.py +++ b/kubernetes/aio/client/models/v1_api_service_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_service_list.py b/kubernetes/aio/client/models/v1_api_service_list.py index c7c2963e6f..3bf4819318 100644 --- a/kubernetes/aio/client/models/v1_api_service_list.py +++ b/kubernetes/aio/client/models/v1_api_service_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_service_spec.py b/kubernetes/aio/client/models/v1_api_service_spec.py index 19ef421abb..b4c7dd10b0 100644 --- a/kubernetes/aio/client/models/v1_api_service_spec.py +++ b/kubernetes/aio/client/models/v1_api_service_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_service_status.py b/kubernetes/aio/client/models/v1_api_service_status.py index 283f62218c..0d0e7633a4 100644 --- a/kubernetes/aio/client/models/v1_api_service_status.py +++ b/kubernetes/aio/client/models/v1_api_service_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_api_versions.py b/kubernetes/aio/client/models/v1_api_versions.py index 9c525d6571..fa570af56b 100644 --- a/kubernetes/aio/client/models/v1_api_versions.py +++ b/kubernetes/aio/client/models/v1_api_versions.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIVersions(BaseModel): diff --git a/kubernetes/aio/client/models/v1_app_armor_profile.py b/kubernetes/aio/client/models/v1_app_armor_profile.py index 118f94888d..6347bd1871 100644 --- a/kubernetes/aio/client/models/v1_app_armor_profile.py +++ b/kubernetes/aio/client/models/v1_app_armor_profile.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AppArmorProfile(BaseModel): diff --git a/kubernetes/aio/client/models/v1_apply_configuration.py b/kubernetes/aio/client/models/v1_apply_configuration.py index 512523d03b..50fb974f06 100644 --- a/kubernetes/aio/client/models/v1_apply_configuration.py +++ b/kubernetes/aio/client/models/v1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ApplyConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_attached_volume.py b/kubernetes/aio/client/models/v1_attached_volume.py index 9b1fe439c9..e72189445d 100644 --- a/kubernetes/aio/client/models/v1_attached_volume.py +++ b/kubernetes/aio/client/models/v1_attached_volume.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AttachedVolume(BaseModel): diff --git a/kubernetes/aio/client/models/v1_audit_annotation.py b/kubernetes/aio/client/models/v1_audit_annotation.py index 4e13a379d8..b2d05a052e 100644 --- a/kubernetes/aio/client/models/v1_audit_annotation.py +++ b/kubernetes/aio/client/models/v1_audit_annotation.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AuditAnnotation(BaseModel): diff --git a/kubernetes/aio/client/models/v1_aws_elastic_block_store_volume_source.py b/kubernetes/aio/client/models/v1_aws_elastic_block_store_volume_source.py index 79e08298c6..34fb33ce51 100644 --- a/kubernetes/aio/client/models/v1_aws_elastic_block_store_volume_source.py +++ b/kubernetes/aio/client/models/v1_aws_elastic_block_store_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AWSElasticBlockStoreVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_azure_disk_volume_source.py b/kubernetes/aio/client/models/v1_azure_disk_volume_source.py index 9f0c225664..efef24025b 100644 --- a/kubernetes/aio/client/models/v1_azure_disk_volume_source.py +++ b/kubernetes/aio/client/models/v1_azure_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureDiskVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_azure_file_persistent_volume_source.py b/kubernetes/aio/client/models/v1_azure_file_persistent_volume_source.py index d63bb3533c..427348ce4e 100644 --- a/kubernetes/aio/client/models/v1_azure_file_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_azure_file_persistent_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureFilePersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_azure_file_volume_source.py b/kubernetes/aio/client/models/v1_azure_file_volume_source.py index 1a8751f35a..c7fa5cbe85 100644 --- a/kubernetes/aio/client/models/v1_azure_file_volume_source.py +++ b/kubernetes/aio/client/models/v1_azure_file_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureFileVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_binding.py b/kubernetes/aio/client/models/v1_binding.py index daddf13462..f3fc74ef18 100644 --- a/kubernetes/aio/client/models/v1_binding.py +++ b/kubernetes/aio/client/models/v1_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Binding(BaseModel): diff --git a/kubernetes/aio/client/models/v1_bound_object_reference.py b/kubernetes/aio/client/models/v1_bound_object_reference.py index 19abddcedf..e01b7c976c 100644 --- a/kubernetes/aio/client/models/v1_bound_object_reference.py +++ b/kubernetes/aio/client/models/v1_bound_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1BoundObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_capabilities.py b/kubernetes/aio/client/models/v1_capabilities.py index 372859a289..ea5da91095 100644 --- a/kubernetes/aio/client/models/v1_capabilities.py +++ b/kubernetes/aio/client/models/v1_capabilities.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Capabilities(BaseModel): diff --git a/kubernetes/aio/client/models/v1_capacity_request_policy.py b/kubernetes/aio/client/models/v1_capacity_request_policy.py index a33009f356..116aee1999 100644 --- a/kubernetes/aio/client/models/v1_capacity_request_policy.py +++ b/kubernetes/aio/client/models/v1_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_capacity_request_policy_range.py b/kubernetes/aio/client/models/v1_capacity_request_policy_range.py index ee412d1616..7f8a4512df 100644 --- a/kubernetes/aio/client/models/v1_capacity_request_policy_range.py +++ b/kubernetes/aio/client/models/v1_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/aio/client/models/v1_capacity_requirements.py b/kubernetes/aio/client/models/v1_capacity_requirements.py index 2938de0926..91dd5ab045 100644 --- a/kubernetes/aio/client/models/v1_capacity_requirements.py +++ b/kubernetes/aio/client/models/v1_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequirements(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cel_device_selector.py b/kubernetes/aio/client/models/v1_cel_device_selector.py index 92b1d68e09..63261265a5 100644 --- a/kubernetes/aio/client/models/v1_cel_device_selector.py +++ b/kubernetes/aio/client/models/v1_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CELDeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ceph_fs_persistent_volume_source.py b/kubernetes/aio/client/models/v1_ceph_fs_persistent_volume_source.py index c02f25d6b9..c13d442274 100644 --- a/kubernetes/aio/client/models/v1_ceph_fs_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_ceph_fs_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CephFSPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ceph_fs_volume_source.py b/kubernetes/aio/client/models/v1_ceph_fs_volume_source.py index 79c05d9bbf..e27a544734 100644 --- a/kubernetes/aio/client/models/v1_ceph_fs_volume_source.py +++ b/kubernetes/aio/client/models/v1_ceph_fs_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CephFSVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_certificate_signing_request.py b/kubernetes/aio/client/models/v1_certificate_signing_request.py index 35c268e96e..a43a326f9a 100644 --- a/kubernetes/aio/client/models/v1_certificate_signing_request.py +++ b/kubernetes/aio/client/models/v1_certificate_signing_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_certificate_signing_request_condition.py b/kubernetes/aio/client/models/v1_certificate_signing_request_condition.py index ae946a1a10..3f4a770131 100644 --- a/kubernetes/aio/client/models/v1_certificate_signing_request_condition.py +++ b/kubernetes/aio/client/models/v1_certificate_signing_request_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_certificate_signing_request_list.py b/kubernetes/aio/client/models/v1_certificate_signing_request_list.py index d50d7afb4c..52987d4734 100644 --- a/kubernetes/aio/client/models/v1_certificate_signing_request_list.py +++ b/kubernetes/aio/client/models/v1_certificate_signing_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_certificate_signing_request_spec.py b/kubernetes/aio/client/models/v1_certificate_signing_request_spec.py index 586f687bf8..321a3b4317 100644 --- a/kubernetes/aio/client/models/v1_certificate_signing_request_spec.py +++ b/kubernetes/aio/client/models/v1_certificate_signing_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_certificate_signing_request_status.py b/kubernetes/aio/client/models/v1_certificate_signing_request_status.py index 7b06df3ef3..525111cf51 100644 --- a/kubernetes/aio/client/models/v1_certificate_signing_request_status.py +++ b/kubernetes/aio/client/models/v1_certificate_signing_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cinder_persistent_volume_source.py b/kubernetes/aio/client/models/v1_cinder_persistent_volume_source.py index 4168391834..4601525734 100644 --- a/kubernetes/aio/client/models/v1_cinder_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_cinder_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CinderPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cinder_volume_source.py b/kubernetes/aio/client/models/v1_cinder_volume_source.py index bf3fda3b1c..86456329d7 100644 --- a/kubernetes/aio/client/models/v1_cinder_volume_source.py +++ b/kubernetes/aio/client/models/v1_cinder_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CinderVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_client_ip_config.py b/kubernetes/aio/client/models/v1_client_ip_config.py index 1879bd4851..710e1ed437 100644 --- a/kubernetes/aio/client/models/v1_client_ip_config.py +++ b/kubernetes/aio/client/models/v1_client_ip_config.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClientIPConfig(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_role.py b/kubernetes/aio/client/models/v1_cluster_role.py index 6d421ad78a..0c92675ef8 100644 --- a/kubernetes/aio/client/models/v1_cluster_role.py +++ b/kubernetes/aio/client/models/v1_cluster_role.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRole(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_role_binding.py b/kubernetes/aio/client/models/v1_cluster_role_binding.py index 5952adac89..47615bd92d 100644 --- a/kubernetes/aio/client/models/v1_cluster_role_binding.py +++ b/kubernetes/aio/client/models/v1_cluster_role_binding.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_role_binding_list.py b/kubernetes/aio/client/models/v1_cluster_role_binding_list.py index 986d62c43c..246d72e7f8 100644 --- a/kubernetes/aio/client/models/v1_cluster_role_binding_list.py +++ b/kubernetes/aio/client/models/v1_cluster_role_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_role_list.py b/kubernetes/aio/client/models/v1_cluster_role_list.py index 756c2e62c3..4270c75700 100644 --- a/kubernetes/aio/client/models/v1_cluster_role_list.py +++ b/kubernetes/aio/client/models/v1_cluster_role_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_trust_bundle.py b/kubernetes/aio/client/models/v1_cluster_trust_bundle.py index 1aa93c9527..fd6287e742 100644 --- a/kubernetes/aio/client/models/v1_cluster_trust_bundle.py +++ b/kubernetes/aio/client/models/v1_cluster_trust_bundle.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundle(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_trust_bundle_list.py b/kubernetes/aio/client/models/v1_cluster_trust_bundle_list.py index 1989f6aad8..31b9b9e5c4 100644 --- a/kubernetes/aio/client/models/v1_cluster_trust_bundle_list.py +++ b/kubernetes/aio/client/models/v1_cluster_trust_bundle_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_trust_bundle_projection.py b/kubernetes/aio/client/models/v1_cluster_trust_bundle_projection.py index 8e7394cbae..235774f449 100644 --- a/kubernetes/aio/client/models/v1_cluster_trust_bundle_projection.py +++ b/kubernetes/aio/client/models/v1_cluster_trust_bundle_projection.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cluster_trust_bundle_spec.py b/kubernetes/aio/client/models/v1_cluster_trust_bundle_spec.py index 542aca5004..0f9771acf0 100644 --- a/kubernetes/aio/client/models/v1_cluster_trust_bundle_spec.py +++ b/kubernetes/aio/client/models/v1_cluster_trust_bundle_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_component_condition.py b/kubernetes/aio/client/models/v1_component_condition.py index f5c70b92e3..e65bb44bed 100644 --- a/kubernetes/aio/client/models/v1_component_condition.py +++ b/kubernetes/aio/client/models/v1_component_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_component_status.py b/kubernetes/aio/client/models/v1_component_status.py index 74d069a9e7..a7ceb4a361 100644 --- a/kubernetes/aio/client/models/v1_component_status.py +++ b/kubernetes/aio/client/models/v1_component_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_component_status_list.py b/kubernetes/aio/client/models/v1_component_status_list.py index e0e7c913c9..e3ec5a96ff 100644 --- a/kubernetes/aio/client/models/v1_component_status_list.py +++ b/kubernetes/aio/client/models/v1_component_status_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentStatusList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_condition.py b/kubernetes/aio/client/models/v1_condition.py index 4960daaf92..5e96354a14 100644 --- a/kubernetes/aio/client/models/v1_condition.py +++ b/kubernetes/aio/client/models/v1_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Condition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map.py b/kubernetes/aio/client/models/v1_config_map.py index 4b19404fbd..cb09f8a8d1 100644 --- a/kubernetes/aio/client/models/v1_config_map.py +++ b/kubernetes/aio/client/models/v1_config_map.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMap(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_env_source.py b/kubernetes/aio/client/models/v1_config_map_env_source.py index 85f7a607a3..df076065b9 100644 --- a/kubernetes/aio/client/models/v1_config_map_env_source.py +++ b/kubernetes/aio/client/models/v1_config_map_env_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapEnvSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_key_selector.py b/kubernetes/aio/client/models/v1_config_map_key_selector.py index d2d5d7f347..d699af511f 100644 --- a/kubernetes/aio/client/models/v1_config_map_key_selector.py +++ b/kubernetes/aio/client/models/v1_config_map_key_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapKeySelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_list.py b/kubernetes/aio/client/models/v1_config_map_list.py index 7b5fad8a57..700c2f2466 100644 --- a/kubernetes/aio/client/models/v1_config_map_list.py +++ b/kubernetes/aio/client/models/v1_config_map_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_node_config_source.py b/kubernetes/aio/client/models/v1_config_map_node_config_source.py index 161a326492..cbe2168034 100644 --- a/kubernetes/aio/client/models/v1_config_map_node_config_source.py +++ b/kubernetes/aio/client/models/v1_config_map_node_config_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapNodeConfigSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_projection.py b/kubernetes/aio/client/models/v1_config_map_projection.py index 161ca33312..4eef269e41 100644 --- a/kubernetes/aio/client/models/v1_config_map_projection.py +++ b/kubernetes/aio/client/models/v1_config_map_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_config_map_volume_source.py b/kubernetes/aio/client/models/v1_config_map_volume_source.py index 4dfcd621b2..51d76f50cf 100644 --- a/kubernetes/aio/client/models/v1_config_map_volume_source.py +++ b/kubernetes/aio/client/models/v1_config_map_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container.py b/kubernetes/aio/client/models/v1_container.py index ae77926e9a..a80f0873f4 100644 --- a/kubernetes/aio/client/models/v1_container.py +++ b/kubernetes/aio/client/models/v1_container.py @@ -36,72 +36,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Container(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_extended_resource_request.py b/kubernetes/aio/client/models/v1_container_extended_resource_request.py index e427d9b7c7..5c33a75d34 100644 --- a/kubernetes/aio/client/models/v1_container_extended_resource_request.py +++ b/kubernetes/aio/client/models/v1_container_extended_resource_request.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerExtendedResourceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_image.py b/kubernetes/aio/client/models/v1_container_image.py index bce4c50740..8245ffdb32 100644 --- a/kubernetes/aio/client/models/v1_container_image.py +++ b/kubernetes/aio/client/models/v1_container_image.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerImage(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_port.py b/kubernetes/aio/client/models/v1_container_port.py index f2585af183..15165315f7 100644 --- a/kubernetes/aio/client/models/v1_container_port.py +++ b/kubernetes/aio/client/models/v1_container_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerPort(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_resize_policy.py b/kubernetes/aio/client/models/v1_container_resize_policy.py index 4322243648..898965ace1 100644 --- a/kubernetes/aio/client/models/v1_container_resize_policy.py +++ b/kubernetes/aio/client/models/v1_container_resize_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerResizePolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_restart_rule.py b/kubernetes/aio/client/models/v1_container_restart_rule.py index 2dd37526a7..00c9d30d20 100644 --- a/kubernetes/aio/client/models/v1_container_restart_rule.py +++ b/kubernetes/aio/client/models/v1_container_restart_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerRestartRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_restart_rule_on_exit_codes.py b/kubernetes/aio/client/models/v1_container_restart_rule_on_exit_codes.py index f3556501c5..80494c1056 100644 --- a/kubernetes/aio/client/models/v1_container_restart_rule_on_exit_codes.py +++ b/kubernetes/aio/client/models/v1_container_restart_rule_on_exit_codes.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerRestartRuleOnExitCodes(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_state.py b/kubernetes/aio/client/models/v1_container_state.py index 05abbb27f5..4965f3bee6 100644 --- a/kubernetes/aio/client/models/v1_container_state.py +++ b/kubernetes/aio/client/models/v1_container_state.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerState(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_state_running.py b/kubernetes/aio/client/models/v1_container_state_running.py index b4632eb940..e9bcda7408 100644 --- a/kubernetes/aio/client/models/v1_container_state_running.py +++ b/kubernetes/aio/client/models/v1_container_state_running.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateRunning(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_state_terminated.py b/kubernetes/aio/client/models/v1_container_state_terminated.py index 9f3e0141e6..d2aaf78d5c 100644 --- a/kubernetes/aio/client/models/v1_container_state_terminated.py +++ b/kubernetes/aio/client/models/v1_container_state_terminated.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateTerminated(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_state_waiting.py b/kubernetes/aio/client/models/v1_container_state_waiting.py index f6c6428a0a..9706c48a6d 100644 --- a/kubernetes/aio/client/models/v1_container_state_waiting.py +++ b/kubernetes/aio/client/models/v1_container_state_waiting.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateWaiting(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_status.py b/kubernetes/aio/client/models/v1_container_status.py index e9eedaf5cb..0895c0d39a 100644 --- a/kubernetes/aio/client/models/v1_container_status.py +++ b/kubernetes/aio/client/models/v1_container_status.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_container_user.py b/kubernetes/aio/client/models/v1_container_user.py index 337d71f9a9..a48826915f 100644 --- a/kubernetes/aio/client/models/v1_container_user.py +++ b/kubernetes/aio/client/models/v1_container_user.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerUser(BaseModel): diff --git a/kubernetes/aio/client/models/v1_controller_revision.py b/kubernetes/aio/client/models/v1_controller_revision.py index ef574478a4..4e1d407316 100644 --- a/kubernetes/aio/client/models/v1_controller_revision.py +++ b/kubernetes/aio/client/models/v1_controller_revision.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ControllerRevision(BaseModel): diff --git a/kubernetes/aio/client/models/v1_controller_revision_list.py b/kubernetes/aio/client/models/v1_controller_revision_list.py index 46ce9119ae..4cad8dfab1 100644 --- a/kubernetes/aio/client/models/v1_controller_revision_list.py +++ b/kubernetes/aio/client/models/v1_controller_revision_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ControllerRevisionList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_counter.py b/kubernetes/aio/client/models/v1_counter.py index e5b245bcb4..637c4558dc 100644 --- a/kubernetes/aio/client/models/v1_counter.py +++ b/kubernetes/aio/client/models/v1_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Counter(BaseModel): diff --git a/kubernetes/aio/client/models/v1_counter_set.py b/kubernetes/aio/client/models/v1_counter_set.py index 22a5572cc1..534e8a6bdb 100644 --- a/kubernetes/aio/client/models/v1_counter_set.py +++ b/kubernetes/aio/client/models/v1_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CounterSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cron_job.py b/kubernetes/aio/client/models/v1_cron_job.py index b691701a66..11c0b3ee47 100644 --- a/kubernetes/aio/client/models/v1_cron_job.py +++ b/kubernetes/aio/client/models/v1_cron_job.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJob(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cron_job_list.py b/kubernetes/aio/client/models/v1_cron_job_list.py index 9ae2ef0451..055a49329e 100644 --- a/kubernetes/aio/client/models/v1_cron_job_list.py +++ b/kubernetes/aio/client/models/v1_cron_job_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cron_job_spec.py b/kubernetes/aio/client/models/v1_cron_job_spec.py index d10d409068..128c2f2283 100644 --- a/kubernetes/aio/client/models/v1_cron_job_spec.py +++ b/kubernetes/aio/client/models/v1_cron_job_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cron_job_status.py b/kubernetes/aio/client/models/v1_cron_job_status.py index ef2f4aa208..52b4ec8aa1 100644 --- a/kubernetes/aio/client/models/v1_cron_job_status.py +++ b/kubernetes/aio/client/models/v1_cron_job_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_cross_version_object_reference.py b/kubernetes/aio/client/models/v1_cross_version_object_reference.py index 3977330a74..e70c008f9c 100644 --- a/kubernetes/aio/client/models/v1_cross_version_object_reference.py +++ b/kubernetes/aio/client/models/v1_cross_version_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CrossVersionObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_driver.py b/kubernetes/aio/client/models/v1_csi_driver.py index c9050bb7b2..c2b9301ec5 100644 --- a/kubernetes/aio/client/models/v1_csi_driver.py +++ b/kubernetes/aio/client/models/v1_csi_driver.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriver(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_driver_list.py b/kubernetes/aio/client/models/v1_csi_driver_list.py index 44845e4a83..b641cb5543 100644 --- a/kubernetes/aio/client/models/v1_csi_driver_list.py +++ b/kubernetes/aio/client/models/v1_csi_driver_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriverList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_driver_spec.py b/kubernetes/aio/client/models/v1_csi_driver_spec.py index 18233084c3..5f9200477e 100644 --- a/kubernetes/aio/client/models/v1_csi_driver_spec.py +++ b/kubernetes/aio/client/models/v1_csi_driver_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriverSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_node.py b/kubernetes/aio/client/models/v1_csi_node.py index b400648dfc..6076d02640 100644 --- a/kubernetes/aio/client/models/v1_csi_node.py +++ b/kubernetes/aio/client/models/v1_csi_node.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINode(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_node_driver.py b/kubernetes/aio/client/models/v1_csi_node_driver.py index 9ed57059fe..b464d215e0 100644 --- a/kubernetes/aio/client/models/v1_csi_node_driver.py +++ b/kubernetes/aio/client/models/v1_csi_node_driver.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeDriver(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_node_list.py b/kubernetes/aio/client/models/v1_csi_node_list.py index dca33a3f14..7c8b9704f9 100644 --- a/kubernetes/aio/client/models/v1_csi_node_list.py +++ b/kubernetes/aio/client/models/v1_csi_node_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_node_spec.py b/kubernetes/aio/client/models/v1_csi_node_spec.py index 89b6388b2b..3e5fe4d698 100644 --- a/kubernetes/aio/client/models/v1_csi_node_spec.py +++ b/kubernetes/aio/client/models/v1_csi_node_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_node_status.py b/kubernetes/aio/client/models/v1_csi_node_status.py index 8692e36250..739178ca7a 100644 --- a/kubernetes/aio/client/models/v1_csi_node_status.py +++ b/kubernetes/aio/client/models/v1_csi_node_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_persistent_volume_source.py b/kubernetes/aio/client/models/v1_csi_persistent_volume_source.py index 91e02922fe..bf83d1b59b 100644 --- a/kubernetes/aio/client/models/v1_csi_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_csi_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_storage_capacity.py b/kubernetes/aio/client/models/v1_csi_storage_capacity.py index 3e55c2436a..94dc7b8f9f 100644 --- a/kubernetes/aio/client/models/v1_csi_storage_capacity.py +++ b/kubernetes/aio/client/models/v1_csi_storage_capacity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIStorageCapacity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_storage_capacity_list.py b/kubernetes/aio/client/models/v1_csi_storage_capacity_list.py index 9ce01e04e2..5cd7c6d876 100644 --- a/kubernetes/aio/client/models/v1_csi_storage_capacity_list.py +++ b/kubernetes/aio/client/models/v1_csi_storage_capacity_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIStorageCapacityList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_csi_volume_source.py b/kubernetes/aio/client/models/v1_csi_volume_source.py index 483531544a..d7c08f8de9 100644 --- a/kubernetes/aio/client/models/v1_csi_volume_source.py +++ b/kubernetes/aio/client/models/v1_csi_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_column_definition.py b/kubernetes/aio/client/models/v1_custom_resource_column_definition.py index 31a5c8e66d..ad4506d929 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_column_definition.py +++ b/kubernetes/aio/client/models/v1_custom_resource_column_definition.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceColumnDefinition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_conversion.py b/kubernetes/aio/client/models/v1_custom_resource_conversion.py index 9c830425b8..979c5671c2 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_conversion.py +++ b/kubernetes/aio/client/models/v1_custom_resource_conversion.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceConversion(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition.py b/kubernetes/aio/client/models/v1_custom_resource_definition.py index 2f866b902b..e3eaf7b0f6 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_condition.py b/kubernetes/aio/client/models/v1_custom_resource_definition_condition.py index 0f84718ee5..fdac3fae3e 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_condition.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_list.py b/kubernetes/aio/client/models/v1_custom_resource_definition_list.py index e5617e16a9..79c1f725e4 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_list.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_names.py b/kubernetes/aio/client/models/v1_custom_resource_definition_names.py index 9ec73f6233..959dd74098 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_names.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_names.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionNames(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_spec.py b/kubernetes/aio/client/models/v1_custom_resource_definition_spec.py index 1aeebfa464..58ad6dd3ee 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_spec.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_status.py b/kubernetes/aio/client/models/v1_custom_resource_definition_status.py index d123049425..11a895bcf1 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_status.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_definition_version.py b/kubernetes/aio/client/models/v1_custom_resource_definition_version.py index 64911dd913..9a9b637a1e 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_definition_version.py +++ b/kubernetes/aio/client/models/v1_custom_resource_definition_version.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionVersion(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_subresource_scale.py b/kubernetes/aio/client/models/v1_custom_resource_subresource_scale.py index a6c0e1fea8..b7174a4aaa 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_subresource_scale.py +++ b/kubernetes/aio/client/models/v1_custom_resource_subresource_scale.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceSubresourceScale(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_subresources.py b/kubernetes/aio/client/models/v1_custom_resource_subresources.py index e32d5879df..5f5c5f0c6c 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_subresources.py +++ b/kubernetes/aio/client/models/v1_custom_resource_subresources.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceSubresources(BaseModel): diff --git a/kubernetes/aio/client/models/v1_custom_resource_validation.py b/kubernetes/aio/client/models/v1_custom_resource_validation.py index 87d835dcdb..0038a82c3a 100644 --- a/kubernetes/aio/client/models/v1_custom_resource_validation.py +++ b/kubernetes/aio/client/models/v1_custom_resource_validation.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceValidation(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_endpoint.py b/kubernetes/aio/client/models/v1_daemon_endpoint.py index e99ce7dd38..db4c9599f8 100644 --- a/kubernetes/aio/client/models/v1_daemon_endpoint.py +++ b/kubernetes/aio/client/models/v1_daemon_endpoint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonEndpoint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set.py b/kubernetes/aio/client/models/v1_daemon_set.py index 915a816322..954ac31ae4 100644 --- a/kubernetes/aio/client/models/v1_daemon_set.py +++ b/kubernetes/aio/client/models/v1_daemon_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set_condition.py b/kubernetes/aio/client/models/v1_daemon_set_condition.py index 3c68a8a691..0e6eff7a76 100644 --- a/kubernetes/aio/client/models/v1_daemon_set_condition.py +++ b/kubernetes/aio/client/models/v1_daemon_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set_list.py b/kubernetes/aio/client/models/v1_daemon_set_list.py index ccf83a3481..deffe39f89 100644 --- a/kubernetes/aio/client/models/v1_daemon_set_list.py +++ b/kubernetes/aio/client/models/v1_daemon_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set_spec.py b/kubernetes/aio/client/models/v1_daemon_set_spec.py index 60749843d0..c0cab3bed8 100644 --- a/kubernetes/aio/client/models/v1_daemon_set_spec.py +++ b/kubernetes/aio/client/models/v1_daemon_set_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set_status.py b/kubernetes/aio/client/models/v1_daemon_set_status.py index b0dc198133..478de774fb 100644 --- a/kubernetes/aio/client/models/v1_daemon_set_status.py +++ b/kubernetes/aio/client/models/v1_daemon_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_daemon_set_update_strategy.py b/kubernetes/aio/client/models/v1_daemon_set_update_strategy.py index cda679e849..a9ca31dcf1 100644 --- a/kubernetes/aio/client/models/v1_daemon_set_update_strategy.py +++ b/kubernetes/aio/client/models/v1_daemon_set_update_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetUpdateStrategy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_delete_options.py b/kubernetes/aio/client/models/v1_delete_options.py index d8b0f37f9f..832bb7e51c 100644 --- a/kubernetes/aio/client/models/v1_delete_options.py +++ b/kubernetes/aio/client/models/v1_delete_options.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeleteOptions(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment.py b/kubernetes/aio/client/models/v1_deployment.py index b018e6146d..5a18ff109c 100644 --- a/kubernetes/aio/client/models/v1_deployment.py +++ b/kubernetes/aio/client/models/v1_deployment.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Deployment(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment_condition.py b/kubernetes/aio/client/models/v1_deployment_condition.py index 6e3a80ea3c..933b4f1cb1 100644 --- a/kubernetes/aio/client/models/v1_deployment_condition.py +++ b/kubernetes/aio/client/models/v1_deployment_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment_list.py b/kubernetes/aio/client/models/v1_deployment_list.py index 02a7484d16..7a5fbaafa5 100644 --- a/kubernetes/aio/client/models/v1_deployment_list.py +++ b/kubernetes/aio/client/models/v1_deployment_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment_spec.py b/kubernetes/aio/client/models/v1_deployment_spec.py index 5da35baa19..c4c8808a16 100644 --- a/kubernetes/aio/client/models/v1_deployment_spec.py +++ b/kubernetes/aio/client/models/v1_deployment_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment_status.py b/kubernetes/aio/client/models/v1_deployment_status.py index ff533a7b4f..bcc182ca93 100644 --- a/kubernetes/aio/client/models/v1_deployment_status.py +++ b/kubernetes/aio/client/models/v1_deployment_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_deployment_strategy.py b/kubernetes/aio/client/models/v1_deployment_strategy.py index e6f689e535..d4c7d35325 100644 --- a/kubernetes/aio/client/models/v1_deployment_strategy.py +++ b/kubernetes/aio/client/models/v1_deployment_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentStrategy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device.py b/kubernetes/aio/client/models/v1_device.py index e3206cefcf..d040a607d9 100644 --- a/kubernetes/aio/client/models/v1_device.py +++ b/kubernetes/aio/client/models/v1_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Device(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_allocation_configuration.py b/kubernetes/aio/client/models/v1_device_allocation_configuration.py index 75bc3306ed..6b758e8e11 100644 --- a/kubernetes/aio/client/models/v1_device_allocation_configuration.py +++ b/kubernetes/aio/client/models/v1_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_allocation_result.py b/kubernetes/aio/client/models/v1_device_allocation_result.py index 75b1c1e33a..f8665f948e 100644 --- a/kubernetes/aio/client/models/v1_device_allocation_result.py +++ b/kubernetes/aio/client/models/v1_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_attribute.py b/kubernetes/aio/client/models/v1_device_attribute.py index 61e5fc669c..0b4d67f626 100644 --- a/kubernetes/aio/client/models/v1_device_attribute.py +++ b/kubernetes/aio/client/models/v1_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_capacity.py b/kubernetes/aio/client/models/v1_device_capacity.py index 4c11c6bf4c..dc5601257f 100644 --- a/kubernetes/aio/client/models/v1_device_capacity.py +++ b/kubernetes/aio/client/models/v1_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceCapacity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_claim.py b/kubernetes/aio/client/models/v1_device_claim.py index 9e50e13dfd..ed8fd1ee1d 100644 --- a/kubernetes/aio/client/models/v1_device_claim.py +++ b/kubernetes/aio/client/models/v1_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_claim_configuration.py b/kubernetes/aio/client/models/v1_device_claim_configuration.py index a44ea9e6de..4671e5ffc7 100644 --- a/kubernetes/aio/client/models/v1_device_claim_configuration.py +++ b/kubernetes/aio/client/models/v1_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_class.py b/kubernetes/aio/client/models/v1_device_class.py index dbc7ff0d6c..4d41679b92 100644 --- a/kubernetes/aio/client/models/v1_device_class.py +++ b/kubernetes/aio/client/models/v1_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_class_configuration.py b/kubernetes/aio/client/models/v1_device_class_configuration.py index e6ad1cae4a..9eb8ad1e1e 100644 --- a/kubernetes/aio/client/models/v1_device_class_configuration.py +++ b/kubernetes/aio/client/models/v1_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_class_list.py b/kubernetes/aio/client/models/v1_device_class_list.py index 6a96b4f5ab..1c0673e10e 100644 --- a/kubernetes/aio/client/models/v1_device_class_list.py +++ b/kubernetes/aio/client/models/v1_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_class_spec.py b/kubernetes/aio/client/models/v1_device_class_spec.py index bbe0a625e9..0d2ba2c616 100644 --- a/kubernetes/aio/client/models/v1_device_class_spec.py +++ b/kubernetes/aio/client/models/v1_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_constraint.py b/kubernetes/aio/client/models/v1_device_constraint.py index c21dcf4725..04a3c1c247 100644 --- a/kubernetes/aio/client/models/v1_device_constraint.py +++ b/kubernetes/aio/client/models/v1_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_counter_consumption.py b/kubernetes/aio/client/models/v1_device_counter_consumption.py index b960a01689..27be5f6ed3 100644 --- a/kubernetes/aio/client/models/v1_device_counter_consumption.py +++ b/kubernetes/aio/client/models/v1_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_derived_attribute.py b/kubernetes/aio/client/models/v1_device_derived_attribute.py index 46309113d9..3bf68843b5 100644 --- a/kubernetes/aio/client/models/v1_device_derived_attribute.py +++ b/kubernetes/aio/client/models/v1_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_request.py b/kubernetes/aio/client/models/v1_device_request.py index b411b43f55..23ba17d79c 100644 --- a/kubernetes/aio/client/models/v1_device_request.py +++ b/kubernetes/aio/client/models/v1_device_request.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_request_allocation_result.py b/kubernetes/aio/client/models/v1_device_request_allocation_result.py index cdf1e51961..4ee9dac21f 100644 --- a/kubernetes/aio/client/models/v1_device_request_allocation_result.py +++ b/kubernetes/aio/client/models/v1_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_selector.py b/kubernetes/aio/client/models/v1_device_selector.py index 9a90621b3d..6ad971d7c5 100644 --- a/kubernetes/aio/client/models/v1_device_selector.py +++ b/kubernetes/aio/client/models/v1_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_sub_request.py b/kubernetes/aio/client/models/v1_device_sub_request.py index 61a355e8ad..265660b749 100644 --- a/kubernetes/aio/client/models/v1_device_sub_request.py +++ b/kubernetes/aio/client/models/v1_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceSubRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint.py b/kubernetes/aio/client/models/v1_device_taint.py index 954c9e529e..882d02bb3e 100644 --- a/kubernetes/aio/client/models/v1_device_taint.py +++ b/kubernetes/aio/client/models/v1_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint_rule.py b/kubernetes/aio/client/models/v1_device_taint_rule.py index 770b1230a8..21a500887d 100644 --- a/kubernetes/aio/client/models/v1_device_taint_rule.py +++ b/kubernetes/aio/client/models/v1_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint_rule_list.py b/kubernetes/aio/client/models/v1_device_taint_rule_list.py index e3bb66f66f..276f43e17a 100644 --- a/kubernetes/aio/client/models/v1_device_taint_rule_list.py +++ b/kubernetes/aio/client/models/v1_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint_rule_spec.py b/kubernetes/aio/client/models/v1_device_taint_rule_spec.py index 00203eacba..7d766bda96 100644 --- a/kubernetes/aio/client/models/v1_device_taint_rule_spec.py +++ b/kubernetes/aio/client/models/v1_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint_rule_status.py b/kubernetes/aio/client/models/v1_device_taint_rule_status.py index de012aa16e..50afb923f2 100644 --- a/kubernetes/aio/client/models/v1_device_taint_rule_status.py +++ b/kubernetes/aio/client/models/v1_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_taint_selector.py b/kubernetes/aio/client/models/v1_device_taint_selector.py index 76b62e2fa9..b75f2b0019 100644 --- a/kubernetes/aio/client/models/v1_device_taint_selector.py +++ b/kubernetes/aio/client/models/v1_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_device_toleration.py b/kubernetes/aio/client/models/v1_device_toleration.py index 407c1110f3..32d5e4427a 100644 --- a/kubernetes/aio/client/models/v1_device_toleration.py +++ b/kubernetes/aio/client/models/v1_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceToleration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_downward_api_projection.py b/kubernetes/aio/client/models/v1_downward_api_projection.py index 87a7fad0cf..3cdc79e590 100644 --- a/kubernetes/aio/client/models/v1_downward_api_projection.py +++ b/kubernetes/aio/client/models/v1_downward_api_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_downward_api_volume_file.py b/kubernetes/aio/client/models/v1_downward_api_volume_file.py index 1ff07fd513..e0d9de4a5e 100644 --- a/kubernetes/aio/client/models/v1_downward_api_volume_file.py +++ b/kubernetes/aio/client/models/v1_downward_api_volume_file.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIVolumeFile(BaseModel): diff --git a/kubernetes/aio/client/models/v1_downward_api_volume_source.py b/kubernetes/aio/client/models/v1_downward_api_volume_source.py index d86c9de23a..7e1a65f725 100644 --- a/kubernetes/aio/client/models/v1_downward_api_volume_source.py +++ b/kubernetes/aio/client/models/v1_downward_api_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_empty_dir_volume_source.py b/kubernetes/aio/client/models/v1_empty_dir_volume_source.py index 4f6174455f..d3f8674ee6 100644 --- a/kubernetes/aio/client/models/v1_empty_dir_volume_source.py +++ b/kubernetes/aio/client/models/v1_empty_dir_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EmptyDirVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint.py b/kubernetes/aio/client/models/v1_endpoint.py index e1a8de85ee..abc34f938b 100644 --- a/kubernetes/aio/client/models/v1_endpoint.py +++ b/kubernetes/aio/client/models/v1_endpoint.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Endpoint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_address.py b/kubernetes/aio/client/models/v1_endpoint_address.py index 7b23e7ff17..9a6da3ae91 100644 --- a/kubernetes/aio/client/models/v1_endpoint_address.py +++ b/kubernetes/aio/client/models/v1_endpoint_address.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointAddress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_conditions.py b/kubernetes/aio/client/models/v1_endpoint_conditions.py index 9bc83ef75e..26419bfdca 100644 --- a/kubernetes/aio/client/models/v1_endpoint_conditions.py +++ b/kubernetes/aio/client/models/v1_endpoint_conditions.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointConditions(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_hints.py b/kubernetes/aio/client/models/v1_endpoint_hints.py index fd45f6b85c..ed1ea738a7 100644 --- a/kubernetes/aio/client/models/v1_endpoint_hints.py +++ b/kubernetes/aio/client/models/v1_endpoint_hints.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointHints(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_slice.py b/kubernetes/aio/client/models/v1_endpoint_slice.py index 9322049c7f..7392c4739e 100644 --- a/kubernetes/aio/client/models/v1_endpoint_slice.py +++ b/kubernetes/aio/client/models/v1_endpoint_slice.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSlice(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_slice_list.py b/kubernetes/aio/client/models/v1_endpoint_slice_list.py index 53d619b6ff..1a59f7553e 100644 --- a/kubernetes/aio/client/models/v1_endpoint_slice_list.py +++ b/kubernetes/aio/client/models/v1_endpoint_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSliceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoint_subset.py b/kubernetes/aio/client/models/v1_endpoint_subset.py index a7408e3c47..6671cb75c1 100644 --- a/kubernetes/aio/client/models/v1_endpoint_subset.py +++ b/kubernetes/aio/client/models/v1_endpoint_subset.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSubset(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoints.py b/kubernetes/aio/client/models/v1_endpoints.py index 94bd17a553..347b3cd920 100644 --- a/kubernetes/aio/client/models/v1_endpoints.py +++ b/kubernetes/aio/client/models/v1_endpoints.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Endpoints(BaseModel): diff --git a/kubernetes/aio/client/models/v1_endpoints_list.py b/kubernetes/aio/client/models/v1_endpoints_list.py index 26bea5ca31..648317ec5d 100644 --- a/kubernetes/aio/client/models/v1_endpoints_list.py +++ b/kubernetes/aio/client/models/v1_endpoints_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointsList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_env_from_source.py b/kubernetes/aio/client/models/v1_env_from_source.py index 1ef20ebf66..8a845ebfdf 100644 --- a/kubernetes/aio/client/models/v1_env_from_source.py +++ b/kubernetes/aio/client/models/v1_env_from_source.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvFromSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_env_var.py b/kubernetes/aio/client/models/v1_env_var.py index dfe22d7554..e72f569ef3 100644 --- a/kubernetes/aio/client/models/v1_env_var.py +++ b/kubernetes/aio/client/models/v1_env_var.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvVar(BaseModel): diff --git a/kubernetes/aio/client/models/v1_env_var_source.py b/kubernetes/aio/client/models/v1_env_var_source.py index 6bb6db0cd7..87fa034a06 100644 --- a/kubernetes/aio/client/models/v1_env_var_source.py +++ b/kubernetes/aio/client/models/v1_env_var_source.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvVarSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ephemeral_container.py b/kubernetes/aio/client/models/v1_ephemeral_container.py index 6c4a6411db..706d15d14e 100644 --- a/kubernetes/aio/client/models/v1_ephemeral_container.py +++ b/kubernetes/aio/client/models/v1_ephemeral_container.py @@ -36,72 +36,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EphemeralContainer(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ephemeral_volume_source.py b/kubernetes/aio/client/models/v1_ephemeral_volume_source.py index fc1d78db9e..70c843f193 100644 --- a/kubernetes/aio/client/models/v1_ephemeral_volume_source.py +++ b/kubernetes/aio/client/models/v1_ephemeral_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EphemeralVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_event_source.py b/kubernetes/aio/client/models/v1_event_source.py index 3e0dc80211..242bc04bb1 100644 --- a/kubernetes/aio/client/models/v1_event_source.py +++ b/kubernetes/aio/client/models/v1_event_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EventSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_eviction.py b/kubernetes/aio/client/models/v1_eviction.py index b473971e01..6b3abb6d35 100644 --- a/kubernetes/aio/client/models/v1_eviction.py +++ b/kubernetes/aio/client/models/v1_eviction.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Eviction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_eviction_responder.py b/kubernetes/aio/client/models/v1_eviction_responder.py index 884e0e9fc6..6065e676e8 100644 --- a/kubernetes/aio/client/models/v1_eviction_responder.py +++ b/kubernetes/aio/client/models/v1_eviction_responder.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EvictionResponder(BaseModel): diff --git a/kubernetes/aio/client/models/v1_exact_device_request.py b/kubernetes/aio/client/models/v1_exact_device_request.py index b0c41c9729..0e1ad0a7b4 100644 --- a/kubernetes/aio/client/models/v1_exact_device_request.py +++ b/kubernetes/aio/client/models/v1_exact_device_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExactDeviceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_exec_action.py b/kubernetes/aio/client/models/v1_exec_action.py index 635de92310..927cc6fee3 100644 --- a/kubernetes/aio/client/models/v1_exec_action.py +++ b/kubernetes/aio/client/models/v1_exec_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExecAction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_exempt_priority_level_configuration.py b/kubernetes/aio/client/models/v1_exempt_priority_level_configuration.py index 0b5a0d40a4..341236b5fb 100644 --- a/kubernetes/aio/client/models/v1_exempt_priority_level_configuration.py +++ b/kubernetes/aio/client/models/v1_exempt_priority_level_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExemptPriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_expression_warning.py b/kubernetes/aio/client/models/v1_expression_warning.py index eae58f9c7f..f1a867e065 100644 --- a/kubernetes/aio/client/models/v1_expression_warning.py +++ b/kubernetes/aio/client/models/v1_expression_warning.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExpressionWarning(BaseModel): diff --git a/kubernetes/aio/client/models/v1_external_documentation.py b/kubernetes/aio/client/models/v1_external_documentation.py index 696ae28fe2..63afe36e62 100644 --- a/kubernetes/aio/client/models/v1_external_documentation.py +++ b/kubernetes/aio/client/models/v1_external_documentation.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExternalDocumentation(BaseModel): diff --git a/kubernetes/aio/client/models/v1_fc_volume_source.py b/kubernetes/aio/client/models/v1_fc_volume_source.py index 5ecba4a217..e476de5684 100644 --- a/kubernetes/aio/client/models/v1_fc_volume_source.py +++ b/kubernetes/aio/client/models/v1_fc_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FCVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_field_selector_attributes.py b/kubernetes/aio/client/models/v1_field_selector_attributes.py index e91e0ea28b..286ce248b0 100644 --- a/kubernetes/aio/client/models/v1_field_selector_attributes.py +++ b/kubernetes/aio/client/models/v1_field_selector_attributes.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FieldSelectorAttributes(BaseModel): diff --git a/kubernetes/aio/client/models/v1_field_selector_requirement.py b/kubernetes/aio/client/models/v1_field_selector_requirement.py index ce7d4d6df0..14472f72f6 100644 --- a/kubernetes/aio/client/models/v1_field_selector_requirement.py +++ b/kubernetes/aio/client/models/v1_field_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FieldSelectorRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_file_key_selector.py b/kubernetes/aio/client/models/v1_file_key_selector.py index 617b44aa36..75788dedb1 100644 --- a/kubernetes/aio/client/models/v1_file_key_selector.py +++ b/kubernetes/aio/client/models/v1_file_key_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FileKeySelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flex_persistent_volume_source.py b/kubernetes/aio/client/models/v1_flex_persistent_volume_source.py index 4aaf21fe87..b8a9ddf78d 100644 --- a/kubernetes/aio/client/models/v1_flex_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_flex_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlexPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flex_volume_source.py b/kubernetes/aio/client/models/v1_flex_volume_source.py index d22a6dfa12..f174fbd3f6 100644 --- a/kubernetes/aio/client/models/v1_flex_volume_source.py +++ b/kubernetes/aio/client/models/v1_flex_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlexVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flocker_volume_source.py b/kubernetes/aio/client/models/v1_flocker_volume_source.py index 582e7debdb..bf9b5e3922 100644 --- a/kubernetes/aio/client/models/v1_flocker_volume_source.py +++ b/kubernetes/aio/client/models/v1_flocker_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlockerVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_distinguisher_method.py b/kubernetes/aio/client/models/v1_flow_distinguisher_method.py index 1a7b0efd3f..5eb06f4b6a 100644 --- a/kubernetes/aio/client/models/v1_flow_distinguisher_method.py +++ b/kubernetes/aio/client/models/v1_flow_distinguisher_method.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowDistinguisherMethod(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_schema.py b/kubernetes/aio/client/models/v1_flow_schema.py index 9cb8f12f25..6fa96da713 100644 --- a/kubernetes/aio/client/models/v1_flow_schema.py +++ b/kubernetes/aio/client/models/v1_flow_schema.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchema(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_schema_condition.py b/kubernetes/aio/client/models/v1_flow_schema_condition.py index 3792f41e95..2d67754b9b 100644 --- a/kubernetes/aio/client/models/v1_flow_schema_condition.py +++ b/kubernetes/aio/client/models/v1_flow_schema_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_schema_list.py b/kubernetes/aio/client/models/v1_flow_schema_list.py index 0055cd65d1..35adc043dc 100644 --- a/kubernetes/aio/client/models/v1_flow_schema_list.py +++ b/kubernetes/aio/client/models/v1_flow_schema_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_schema_spec.py b/kubernetes/aio/client/models/v1_flow_schema_spec.py index a1bb11d3fc..f045d7ec12 100644 --- a/kubernetes/aio/client/models/v1_flow_schema_spec.py +++ b/kubernetes/aio/client/models/v1_flow_schema_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_flow_schema_status.py b/kubernetes/aio/client/models/v1_flow_schema_status.py index 24fbb1f954..230aa1da90 100644 --- a/kubernetes/aio/client/models/v1_flow_schema_status.py +++ b/kubernetes/aio/client/models/v1_flow_schema_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_for_node.py b/kubernetes/aio/client/models/v1_for_node.py index 90abc18c94..40cde73048 100644 --- a/kubernetes/aio/client/models/v1_for_node.py +++ b/kubernetes/aio/client/models/v1_for_node.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ForNode(BaseModel): diff --git a/kubernetes/aio/client/models/v1_for_zone.py b/kubernetes/aio/client/models/v1_for_zone.py index 642f5d708c..998d057c13 100644 --- a/kubernetes/aio/client/models/v1_for_zone.py +++ b/kubernetes/aio/client/models/v1_for_zone.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ForZone(BaseModel): diff --git a/kubernetes/aio/client/models/v1_gce_persistent_disk_volume_source.py b/kubernetes/aio/client/models/v1_gce_persistent_disk_volume_source.py index 797cb4518b..f8f33e352e 100644 --- a/kubernetes/aio/client/models/v1_gce_persistent_disk_volume_source.py +++ b/kubernetes/aio/client/models/v1_gce_persistent_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GCEPersistentDiskVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_git_repo_volume_source.py b/kubernetes/aio/client/models/v1_git_repo_volume_source.py index 119e4a3e87..562786ca38 100644 --- a/kubernetes/aio/client/models/v1_git_repo_volume_source.py +++ b/kubernetes/aio/client/models/v1_git_repo_volume_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GitRepoVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_glusterfs_persistent_volume_source.py b/kubernetes/aio/client/models/v1_glusterfs_persistent_volume_source.py index 97b9ab1bc5..6683d00a3e 100644 --- a/kubernetes/aio/client/models/v1_glusterfs_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_glusterfs_persistent_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GlusterfsPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_glusterfs_volume_source.py b/kubernetes/aio/client/models/v1_glusterfs_volume_source.py index e312638804..a67c97daa0 100644 --- a/kubernetes/aio/client/models/v1_glusterfs_volume_source.py +++ b/kubernetes/aio/client/models/v1_glusterfs_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GlusterfsVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_group_resource.py b/kubernetes/aio/client/models/v1_group_resource.py index 05acb363f2..10e0ce9f05 100644 --- a/kubernetes/aio/client/models/v1_group_resource.py +++ b/kubernetes/aio/client/models/v1_group_resource.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupResource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_group_subject.py b/kubernetes/aio/client/models/v1_group_subject.py index c923962366..5f44444e6d 100644 --- a/kubernetes/aio/client/models/v1_group_subject.py +++ b/kubernetes/aio/client/models/v1_group_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupSubject(BaseModel): diff --git a/kubernetes/aio/client/models/v1_group_version_for_discovery.py b/kubernetes/aio/client/models/v1_group_version_for_discovery.py index e1b1e0a8f9..0ea97b7c62 100644 --- a/kubernetes/aio/client/models/v1_group_version_for_discovery.py +++ b/kubernetes/aio/client/models/v1_group_version_for_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupVersionForDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v1_group_version_kind.py b/kubernetes/aio/client/models/v1_group_version_kind.py index e2b2bc337e..3eefe914bf 100644 --- a/kubernetes/aio/client/models/v1_group_version_kind.py +++ b/kubernetes/aio/client/models/v1_group_version_kind.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupVersionKind(BaseModel): diff --git a/kubernetes/aio/client/models/v1_grpc_action.py b/kubernetes/aio/client/models/v1_grpc_action.py index 2dd0bbb200..d970ddd04b 100644 --- a/kubernetes/aio/client/models/v1_grpc_action.py +++ b/kubernetes/aio/client/models/v1_grpc_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GRPCAction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler.py b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler.py index 1863b4bc69..ca156a02d0 100644 --- a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler.py +++ b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscaler(BaseModel): diff --git a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_list.py b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_list.py index d767cfd275..b43400e54d 100644 --- a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_list.py +++ b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_spec.py b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_spec.py index b03bc2b2e2..769425d453 100644 --- a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_spec.py +++ b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_status.py b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_status.py index ffd3b66ff7..fb1a7ca888 100644 --- a/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_status.py +++ b/kubernetes/aio/client/models/v1_horizontal_pod_autoscaler_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_host_alias.py b/kubernetes/aio/client/models/v1_host_alias.py index 362ee5bb7b..dd6e326964 100644 --- a/kubernetes/aio/client/models/v1_host_alias.py +++ b/kubernetes/aio/client/models/v1_host_alias.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostAlias(BaseModel): diff --git a/kubernetes/aio/client/models/v1_host_ip.py b/kubernetes/aio/client/models/v1_host_ip.py index 0471339e19..255e7e3a42 100644 --- a/kubernetes/aio/client/models/v1_host_ip.py +++ b/kubernetes/aio/client/models/v1_host_ip.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostIP(BaseModel): diff --git a/kubernetes/aio/client/models/v1_host_path_volume_source.py b/kubernetes/aio/client/models/v1_host_path_volume_source.py index 6eb3682148..6c3f721c21 100644 --- a/kubernetes/aio/client/models/v1_host_path_volume_source.py +++ b/kubernetes/aio/client/models/v1_host_path_volume_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostPathVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_http_get_action.py b/kubernetes/aio/client/models/v1_http_get_action.py index 0ce49939bf..217552e702 100644 --- a/kubernetes/aio/client/models/v1_http_get_action.py +++ b/kubernetes/aio/client/models/v1_http_get_action.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPGetAction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_http_header.py b/kubernetes/aio/client/models/v1_http_header.py index 5e0bf37dfa..922e6f15ca 100644 --- a/kubernetes/aio/client/models/v1_http_header.py +++ b/kubernetes/aio/client/models/v1_http_header.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPHeader(BaseModel): diff --git a/kubernetes/aio/client/models/v1_http_ingress_path.py b/kubernetes/aio/client/models/v1_http_ingress_path.py index 23c7915eb9..660c787766 100644 --- a/kubernetes/aio/client/models/v1_http_ingress_path.py +++ b/kubernetes/aio/client/models/v1_http_ingress_path.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPIngressPath(BaseModel): diff --git a/kubernetes/aio/client/models/v1_http_ingress_rule_value.py b/kubernetes/aio/client/models/v1_http_ingress_rule_value.py index d2eaccebbe..d1c7c379a0 100644 --- a/kubernetes/aio/client/models/v1_http_ingress_rule_value.py +++ b/kubernetes/aio/client/models/v1_http_ingress_rule_value.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPIngressRuleValue(BaseModel): diff --git a/kubernetes/aio/client/models/v1_image_volume_source.py b/kubernetes/aio/client/models/v1_image_volume_source.py index 870653ecd3..e759579c0c 100644 --- a/kubernetes/aio/client/models/v1_image_volume_source.py +++ b/kubernetes/aio/client/models/v1_image_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ImageVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_image_volume_status.py b/kubernetes/aio/client/models/v1_image_volume_status.py index 7dcf748450..46b9229f7d 100644 --- a/kubernetes/aio/client/models/v1_image_volume_status.py +++ b/kubernetes/aio/client/models/v1_image_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ImageVolumeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress.py b/kubernetes/aio/client/models/v1_ingress.py index 93f99b33a9..c61b020766 100644 --- a/kubernetes/aio/client/models/v1_ingress.py +++ b/kubernetes/aio/client/models/v1_ingress.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Ingress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_backend.py b/kubernetes/aio/client/models/v1_ingress_backend.py index 0ffb98ae4d..b77f9d1fc6 100644 --- a/kubernetes/aio/client/models/v1_ingress_backend.py +++ b/kubernetes/aio/client/models/v1_ingress_backend.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressBackend(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_class.py b/kubernetes/aio/client/models/v1_ingress_class.py index 94f36d7172..035b1436d4 100644 --- a/kubernetes/aio/client/models/v1_ingress_class.py +++ b/kubernetes/aio/client/models/v1_ingress_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_class_list.py b/kubernetes/aio/client/models/v1_ingress_class_list.py index 5986d6e6c2..01a602cb2c 100644 --- a/kubernetes/aio/client/models/v1_ingress_class_list.py +++ b/kubernetes/aio/client/models/v1_ingress_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_class_parameters_reference.py b/kubernetes/aio/client/models/v1_ingress_class_parameters_reference.py index 0270a70f7e..50b805def2 100644 --- a/kubernetes/aio/client/models/v1_ingress_class_parameters_reference.py +++ b/kubernetes/aio/client/models/v1_ingress_class_parameters_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassParametersReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_class_spec.py b/kubernetes/aio/client/models/v1_ingress_class_spec.py index a1a95098c1..1e0e569c11 100644 --- a/kubernetes/aio/client/models/v1_ingress_class_spec.py +++ b/kubernetes/aio/client/models/v1_ingress_class_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_list.py b/kubernetes/aio/client/models/v1_ingress_list.py index 8060902d90..af06ee54fb 100644 --- a/kubernetes/aio/client/models/v1_ingress_list.py +++ b/kubernetes/aio/client/models/v1_ingress_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_load_balancer_ingress.py b/kubernetes/aio/client/models/v1_ingress_load_balancer_ingress.py index 7935e1a189..041e9577d6 100644 --- a/kubernetes/aio/client/models/v1_ingress_load_balancer_ingress.py +++ b/kubernetes/aio/client/models/v1_ingress_load_balancer_ingress.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressLoadBalancerIngress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_load_balancer_status.py b/kubernetes/aio/client/models/v1_ingress_load_balancer_status.py index 3361e4df39..ea3bea44b4 100644 --- a/kubernetes/aio/client/models/v1_ingress_load_balancer_status.py +++ b/kubernetes/aio/client/models/v1_ingress_load_balancer_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressLoadBalancerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_port_status.py b/kubernetes/aio/client/models/v1_ingress_port_status.py index 141179d147..7733590a34 100644 --- a/kubernetes/aio/client/models/v1_ingress_port_status.py +++ b/kubernetes/aio/client/models/v1_ingress_port_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressPortStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_rule.py b/kubernetes/aio/client/models/v1_ingress_rule.py index 0efd52df45..29733a6077 100644 --- a/kubernetes/aio/client/models/v1_ingress_rule.py +++ b/kubernetes/aio/client/models/v1_ingress_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_service_backend.py b/kubernetes/aio/client/models/v1_ingress_service_backend.py index 4b6e43eb35..673a6dbe41 100644 --- a/kubernetes/aio/client/models/v1_ingress_service_backend.py +++ b/kubernetes/aio/client/models/v1_ingress_service_backend.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressServiceBackend(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_spec.py b/kubernetes/aio/client/models/v1_ingress_spec.py index 2fc93ce0d6..a1fc1a86b5 100644 --- a/kubernetes/aio/client/models/v1_ingress_spec.py +++ b/kubernetes/aio/client/models/v1_ingress_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_status.py b/kubernetes/aio/client/models/v1_ingress_status.py index af1aed2e75..7a444ee726 100644 --- a/kubernetes/aio/client/models/v1_ingress_status.py +++ b/kubernetes/aio/client/models/v1_ingress_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ingress_tls.py b/kubernetes/aio/client/models/v1_ingress_tls.py index 7282cdee97..7f109b4e23 100644 --- a/kubernetes/aio/client/models/v1_ingress_tls.py +++ b/kubernetes/aio/client/models/v1_ingress_tls.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressTLS(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ip_address.py b/kubernetes/aio/client/models/v1_ip_address.py index f1bc7e9b0d..673c4b541c 100644 --- a/kubernetes/aio/client/models/v1_ip_address.py +++ b/kubernetes/aio/client/models/v1_ip_address.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ip_address_list.py b/kubernetes/aio/client/models/v1_ip_address_list.py index 8e70ce1729..86471104bc 100644 --- a/kubernetes/aio/client/models/v1_ip_address_list.py +++ b/kubernetes/aio/client/models/v1_ip_address_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddressList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ip_address_spec.py b/kubernetes/aio/client/models/v1_ip_address_spec.py index 0e3579a0a9..b874b81bb1 100644 --- a/kubernetes/aio/client/models/v1_ip_address_spec.py +++ b/kubernetes/aio/client/models/v1_ip_address_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddressSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_ip_block.py b/kubernetes/aio/client/models/v1_ip_block.py index c203fda4d6..160063731f 100644 --- a/kubernetes/aio/client/models/v1_ip_block.py +++ b/kubernetes/aio/client/models/v1_ip_block.py @@ -26,72 +26,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPBlock(BaseModel): diff --git a/kubernetes/aio/client/models/v1_iscsi_persistent_volume_source.py b/kubernetes/aio/client/models/v1_iscsi_persistent_volume_source.py index 82ebc28f3d..27f49203b0 100644 --- a/kubernetes/aio/client/models/v1_iscsi_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_iscsi_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ISCSIPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_iscsi_volume_source.py b/kubernetes/aio/client/models/v1_iscsi_volume_source.py index e9695c2e72..48fc39b9db 100644 --- a/kubernetes/aio/client/models/v1_iscsi_volume_source.py +++ b/kubernetes/aio/client/models/v1_iscsi_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ISCSIVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job.py b/kubernetes/aio/client/models/v1_job.py index 5f62f28e28..5a4b4dfda7 100644 --- a/kubernetes/aio/client/models/v1_job.py +++ b/kubernetes/aio/client/models/v1_job.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Job(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_condition.py b/kubernetes/aio/client/models/v1_job_condition.py index ed8300c314..e35d11cd1d 100644 --- a/kubernetes/aio/client/models/v1_job_condition.py +++ b/kubernetes/aio/client/models/v1_job_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_list.py b/kubernetes/aio/client/models/v1_job_list.py index 95e5e4c354..7946c64905 100644 --- a/kubernetes/aio/client/models/v1_job_list.py +++ b/kubernetes/aio/client/models/v1_job_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_scheduling_configuration.py b/kubernetes/aio/client/models/v1_job_scheduling_configuration.py index 48910f4a2a..dc2fb2e816 100644 --- a/kubernetes/aio/client/models/v1_job_scheduling_configuration.py +++ b/kubernetes/aio/client/models/v1_job_scheduling_configuration.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobSchedulingConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_spec.py b/kubernetes/aio/client/models/v1_job_spec.py index ce007927a8..3cb151ce54 100644 --- a/kubernetes/aio/client/models/v1_job_spec.py +++ b/kubernetes/aio/client/models/v1_job_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_status.py b/kubernetes/aio/client/models/v1_job_status.py index 46022b5bbb..d1e873ad3b 100644 --- a/kubernetes/aio/client/models/v1_job_status.py +++ b/kubernetes/aio/client/models/v1_job_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_job_template_spec.py b/kubernetes/aio/client/models/v1_job_template_spec.py index 5619d7ec68..f2d11fc188 100644 --- a/kubernetes/aio/client/models/v1_job_template_spec.py +++ b/kubernetes/aio/client/models/v1_job_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobTemplateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_json_patch.py b/kubernetes/aio/client/models/v1_json_patch.py index 4926a82709..f79a9c7dc3 100644 --- a/kubernetes/aio/client/models/v1_json_patch.py +++ b/kubernetes/aio/client/models/v1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JSONPatch(BaseModel): diff --git a/kubernetes/aio/client/models/v1_json_schema_props.py b/kubernetes/aio/client/models/v1_json_schema_props.py index 018e37fc14..2b5db35a67 100644 --- a/kubernetes/aio/client/models/v1_json_schema_props.py +++ b/kubernetes/aio/client/models/v1_json_schema_props.py @@ -28,72 +28,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JSONSchemaProps(BaseModel): diff --git a/kubernetes/aio/client/models/v1_key_to_path.py b/kubernetes/aio/client/models/v1_key_to_path.py index 7caa268847..9c5738ab98 100644 --- a/kubernetes/aio/client/models/v1_key_to_path.py +++ b/kubernetes/aio/client/models/v1_key_to_path.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1KeyToPath(BaseModel): diff --git a/kubernetes/aio/client/models/v1_label_selector.py b/kubernetes/aio/client/models/v1_label_selector.py index 4093f3c227..2573db34d6 100644 --- a/kubernetes/aio/client/models/v1_label_selector.py +++ b/kubernetes/aio/client/models/v1_label_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_label_selector_attributes.py b/kubernetes/aio/client/models/v1_label_selector_attributes.py index 32fc404aa9..968d4ed0d7 100644 --- a/kubernetes/aio/client/models/v1_label_selector_attributes.py +++ b/kubernetes/aio/client/models/v1_label_selector_attributes.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelectorAttributes(BaseModel): diff --git a/kubernetes/aio/client/models/v1_label_selector_requirement.py b/kubernetes/aio/client/models/v1_label_selector_requirement.py index f34bc3b463..9bbec089e1 100644 --- a/kubernetes/aio/client/models/v1_label_selector_requirement.py +++ b/kubernetes/aio/client/models/v1_label_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelectorRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_lease.py b/kubernetes/aio/client/models/v1_lease.py index e4f0295d9e..c11083ae0f 100644 --- a/kubernetes/aio/client/models/v1_lease.py +++ b/kubernetes/aio/client/models/v1_lease.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Lease(BaseModel): diff --git a/kubernetes/aio/client/models/v1_lease_list.py b/kubernetes/aio/client/models/v1_lease_list.py index a7e393f7ee..343e3f815a 100644 --- a/kubernetes/aio/client/models/v1_lease_list.py +++ b/kubernetes/aio/client/models/v1_lease_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LeaseList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_lease_spec.py b/kubernetes/aio/client/models/v1_lease_spec.py index 4e23aafe4b..b0ab2cd7e7 100644 --- a/kubernetes/aio/client/models/v1_lease_spec.py +++ b/kubernetes/aio/client/models/v1_lease_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LeaseSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_lifecycle.py b/kubernetes/aio/client/models/v1_lifecycle.py index 358a7b0f4a..a72fa44805 100644 --- a/kubernetes/aio/client/models/v1_lifecycle.py +++ b/kubernetes/aio/client/models/v1_lifecycle.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Lifecycle(BaseModel): diff --git a/kubernetes/aio/client/models/v1_lifecycle_handler.py b/kubernetes/aio/client/models/v1_lifecycle_handler.py index 76ee75368b..1696e53533 100644 --- a/kubernetes/aio/client/models/v1_lifecycle_handler.py +++ b/kubernetes/aio/client/models/v1_lifecycle_handler.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LifecycleHandler(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limit_range.py b/kubernetes/aio/client/models/v1_limit_range.py index 69a04b2b67..5a114362e4 100644 --- a/kubernetes/aio/client/models/v1_limit_range.py +++ b/kubernetes/aio/client/models/v1_limit_range.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRange(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limit_range_item.py b/kubernetes/aio/client/models/v1_limit_range_item.py index 05f3fe45bb..772ba42b74 100644 --- a/kubernetes/aio/client/models/v1_limit_range_item.py +++ b/kubernetes/aio/client/models/v1_limit_range_item.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeItem(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limit_range_list.py b/kubernetes/aio/client/models/v1_limit_range_list.py index 34e0d1f6bb..0fa78ac1e1 100644 --- a/kubernetes/aio/client/models/v1_limit_range_list.py +++ b/kubernetes/aio/client/models/v1_limit_range_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limit_range_spec.py b/kubernetes/aio/client/models/v1_limit_range_spec.py index c9f8b42234..43e90b68d5 100644 --- a/kubernetes/aio/client/models/v1_limit_range_spec.py +++ b/kubernetes/aio/client/models/v1_limit_range_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limit_response.py b/kubernetes/aio/client/models/v1_limit_response.py index 288b163607..90abb894fc 100644 --- a/kubernetes/aio/client/models/v1_limit_response.py +++ b/kubernetes/aio/client/models/v1_limit_response.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitResponse(BaseModel): diff --git a/kubernetes/aio/client/models/v1_limited_priority_level_configuration.py b/kubernetes/aio/client/models/v1_limited_priority_level_configuration.py index 48645de6a7..f5809fe748 100644 --- a/kubernetes/aio/client/models/v1_limited_priority_level_configuration.py +++ b/kubernetes/aio/client/models/v1_limited_priority_level_configuration.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitedPriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_linux_container_user.py b/kubernetes/aio/client/models/v1_linux_container_user.py index e91e29517a..b1d2e3168b 100644 --- a/kubernetes/aio/client/models/v1_linux_container_user.py +++ b/kubernetes/aio/client/models/v1_linux_container_user.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LinuxContainerUser(BaseModel): diff --git a/kubernetes/aio/client/models/v1_list_meta.py b/kubernetes/aio/client/models/v1_list_meta.py index 0f434c728a..db1ab58282 100644 --- a/kubernetes/aio/client/models/v1_list_meta.py +++ b/kubernetes/aio/client/models/v1_list_meta.py @@ -27,72 +27,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ListMeta(BaseModel): diff --git a/kubernetes/aio/client/models/v1_load_balancer_ingress.py b/kubernetes/aio/client/models/v1_load_balancer_ingress.py index 1e2a823c7f..7161b2747f 100644 --- a/kubernetes/aio/client/models/v1_load_balancer_ingress.py +++ b/kubernetes/aio/client/models/v1_load_balancer_ingress.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LoadBalancerIngress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_load_balancer_status.py b/kubernetes/aio/client/models/v1_load_balancer_status.py index 1b1cb0780d..8b874f7b1d 100644 --- a/kubernetes/aio/client/models/v1_load_balancer_status.py +++ b/kubernetes/aio/client/models/v1_load_balancer_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LoadBalancerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_local_object_reference.py b/kubernetes/aio/client/models/v1_local_object_reference.py index 3dae59c1c3..3abbc01eac 100644 --- a/kubernetes/aio/client/models/v1_local_object_reference.py +++ b/kubernetes/aio/client/models/v1_local_object_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_local_subject_access_review.py b/kubernetes/aio/client/models/v1_local_subject_access_review.py index 4735a511d0..dc2ac009d6 100644 --- a/kubernetes/aio/client/models/v1_local_subject_access_review.py +++ b/kubernetes/aio/client/models/v1_local_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalSubjectAccessReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_local_volume_source.py b/kubernetes/aio/client/models/v1_local_volume_source.py index a7b6eb7eca..fad866db28 100644 --- a/kubernetes/aio/client/models/v1_local_volume_source.py +++ b/kubernetes/aio/client/models/v1_local_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_managed_fields_entry.py b/kubernetes/aio/client/models/v1_managed_fields_entry.py index 94ff5a8dfd..1a2de268d5 100644 --- a/kubernetes/aio/client/models/v1_managed_fields_entry.py +++ b/kubernetes/aio/client/models/v1_managed_fields_entry.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ManagedFieldsEntry(BaseModel): diff --git a/kubernetes/aio/client/models/v1_match_condition.py b/kubernetes/aio/client/models/v1_match_condition.py index 3b9494cfb0..a7ba28b1a3 100644 --- a/kubernetes/aio/client/models/v1_match_condition.py +++ b/kubernetes/aio/client/models/v1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MatchCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_match_resources.py b/kubernetes/aio/client/models/v1_match_resources.py index 4c5e7bb8b0..2e3283b559 100644 --- a/kubernetes/aio/client/models/v1_match_resources.py +++ b/kubernetes/aio/client/models/v1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MatchResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1_modify_volume_status.py b/kubernetes/aio/client/models/v1_modify_volume_status.py index c2e6417c3d..d3c7d235ae 100644 --- a/kubernetes/aio/client/models/v1_modify_volume_status.py +++ b/kubernetes/aio/client/models/v1_modify_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ModifyVolumeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy.py b/kubernetes/aio/client/models/v1_mutating_admission_policy.py index 8197031b11..b61d58d7c9 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding.py b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding.py index b13f463a15..77b45b8059 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_list.py b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_list.py index d764078803..0d33c87ef9 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_list.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_spec.py b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_spec.py index e46d53ea57..6831355079 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy_list.py b/kubernetes/aio/client/models/v1_mutating_admission_policy_list.py index 2756d944bd..5274fb2e77 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy_list.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_admission_policy_spec.py b/kubernetes/aio/client/models/v1_mutating_admission_policy_spec.py index 90262630bb..783a6506d2 100644 --- a/kubernetes/aio/client/models/v1_mutating_admission_policy_spec.py +++ b/kubernetes/aio/client/models/v1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_webhook.py b/kubernetes/aio/client/models/v1_mutating_webhook.py index cea8e91ace..5250f512b7 100644 --- a/kubernetes/aio/client/models/v1_mutating_webhook.py +++ b/kubernetes/aio/client/models/v1_mutating_webhook.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhook(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_webhook_configuration.py b/kubernetes/aio/client/models/v1_mutating_webhook_configuration.py index 1d265c68f0..e5a8595742 100644 --- a/kubernetes/aio/client/models/v1_mutating_webhook_configuration.py +++ b/kubernetes/aio/client/models/v1_mutating_webhook_configuration.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhookConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutating_webhook_configuration_list.py b/kubernetes/aio/client/models/v1_mutating_webhook_configuration_list.py index 4dcec71549..982f29288a 100644 --- a/kubernetes/aio/client/models/v1_mutating_webhook_configuration_list.py +++ b/kubernetes/aio/client/models/v1_mutating_webhook_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhookConfigurationList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_mutation.py b/kubernetes/aio/client/models/v1_mutation.py index 32dad47e98..cf4eed74cb 100644 --- a/kubernetes/aio/client/models/v1_mutation.py +++ b/kubernetes/aio/client/models/v1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Mutation(BaseModel): diff --git a/kubernetes/aio/client/models/v1_named_rule_with_operations.py b/kubernetes/aio/client/models/v1_named_rule_with_operations.py index 961fbc5561..0a3c87537e 100644 --- a/kubernetes/aio/client/models/v1_named_rule_with_operations.py +++ b/kubernetes/aio/client/models/v1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/aio/client/models/v1_namespace.py b/kubernetes/aio/client/models/v1_namespace.py index 1973f3949f..ef89919365 100644 --- a/kubernetes/aio/client/models/v1_namespace.py +++ b/kubernetes/aio/client/models/v1_namespace.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Namespace(BaseModel): diff --git a/kubernetes/aio/client/models/v1_namespace_condition.py b/kubernetes/aio/client/models/v1_namespace_condition.py index 3e7e3910b6..5979674389 100644 --- a/kubernetes/aio/client/models/v1_namespace_condition.py +++ b/kubernetes/aio/client/models/v1_namespace_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_namespace_list.py b/kubernetes/aio/client/models/v1_namespace_list.py index 48f3537b09..2be3eedacd 100644 --- a/kubernetes/aio/client/models/v1_namespace_list.py +++ b/kubernetes/aio/client/models/v1_namespace_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_namespace_spec.py b/kubernetes/aio/client/models/v1_namespace_spec.py index 40dbf609cd..cd21fd2819 100644 --- a/kubernetes/aio/client/models/v1_namespace_spec.py +++ b/kubernetes/aio/client/models/v1_namespace_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_namespace_status.py b/kubernetes/aio/client/models/v1_namespace_status.py index befa308d1e..87da55b08d 100644 --- a/kubernetes/aio/client/models/v1_namespace_status.py +++ b/kubernetes/aio/client/models/v1_namespace_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_device_data.py b/kubernetes/aio/client/models/v1_network_device_data.py index 697b7c2c61..6d78134244 100644 --- a/kubernetes/aio/client/models/v1_network_device_data.py +++ b/kubernetes/aio/client/models/v1_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkDeviceData(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy.py b/kubernetes/aio/client/models/v1_network_policy.py index 572f7d48d9..4c4e2beb07 100644 --- a/kubernetes/aio/client/models/v1_network_policy.py +++ b/kubernetes/aio/client/models/v1_network_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_egress_rule.py b/kubernetes/aio/client/models/v1_network_policy_egress_rule.py index 6450249783..9481855612 100644 --- a/kubernetes/aio/client/models/v1_network_policy_egress_rule.py +++ b/kubernetes/aio/client/models/v1_network_policy_egress_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyEgressRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_ingress_rule.py b/kubernetes/aio/client/models/v1_network_policy_ingress_rule.py index 4d3c7d40f1..5fd5bfe990 100644 --- a/kubernetes/aio/client/models/v1_network_policy_ingress_rule.py +++ b/kubernetes/aio/client/models/v1_network_policy_ingress_rule.py @@ -28,72 +28,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyIngressRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_list.py b/kubernetes/aio/client/models/v1_network_policy_list.py index df7cee7072..2e73807a82 100644 --- a/kubernetes/aio/client/models/v1_network_policy_list.py +++ b/kubernetes/aio/client/models/v1_network_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_peer.py b/kubernetes/aio/client/models/v1_network_policy_peer.py index c66f4c9733..d14029b0c5 100644 --- a/kubernetes/aio/client/models/v1_network_policy_peer.py +++ b/kubernetes/aio/client/models/v1_network_policy_peer.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyPeer(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_port.py b/kubernetes/aio/client/models/v1_network_policy_port.py index 3aba96368d..76e3c0541b 100644 --- a/kubernetes/aio/client/models/v1_network_policy_port.py +++ b/kubernetes/aio/client/models/v1_network_policy_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyPort(BaseModel): diff --git a/kubernetes/aio/client/models/v1_network_policy_spec.py b/kubernetes/aio/client/models/v1_network_policy_spec.py index 62830937a9..74b0e4b4f4 100644 --- a/kubernetes/aio/client/models/v1_network_policy_spec.py +++ b/kubernetes/aio/client/models/v1_network_policy_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicySpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_nfs_volume_source.py b/kubernetes/aio/client/models/v1_nfs_volume_source.py index d788ac6150..3e0e9999b8 100644 --- a/kubernetes/aio/client/models/v1_nfs_volume_source.py +++ b/kubernetes/aio/client/models/v1_nfs_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NFSVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node.py b/kubernetes/aio/client/models/v1_node.py index b6bb9395b7..d13bdb3d1d 100644 --- a/kubernetes/aio/client/models/v1_node.py +++ b/kubernetes/aio/client/models/v1_node.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Node(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_address.py b/kubernetes/aio/client/models/v1_node_address.py index 80ee22be5b..dc0b1e7ab3 100644 --- a/kubernetes/aio/client/models/v1_node_address.py +++ b/kubernetes/aio/client/models/v1_node_address.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAddress(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_affinity.py b/kubernetes/aio/client/models/v1_node_affinity.py index 685a49435b..350d51e5fe 100644 --- a/kubernetes/aio/client/models/v1_node_affinity.py +++ b/kubernetes/aio/client/models/v1_node_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAffinity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_mapped_resources.py b/kubernetes/aio/client/models/v1_node_allocatable_mapped_resources.py index 3fd8739210..40b33dd7f4 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_mapped_resources.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_mapped_resources.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableMappedResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_mapping.py b/kubernetes/aio/client/models/v1_node_allocatable_mapping.py index ccb1f86ad3..4da0f64ac8 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_mapping.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_overhead.py b/kubernetes/aio/client/models/v1_node_allocatable_overhead.py index cbb994195b..23f9c40607 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_overhead.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_overhead_resources.py b/kubernetes/aio/client/models/v1_node_allocatable_overhead_resources.py index aba85fbdee..b32496599b 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_overhead_resources.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_overhead_resources.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableOverheadResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_resource.py b/kubernetes/aio/client/models/v1_node_allocatable_resource.py index 2442c8022c..7397f1713a 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_resource.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableResource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_allocatable_resource_claim_status.py b/kubernetes/aio/client/models/v1_node_allocatable_resource_claim_status.py index 72a173f291..46067f7d89 100644 --- a/kubernetes/aio/client/models/v1_node_allocatable_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1_node_allocatable_resource_claim_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_condition.py b/kubernetes/aio/client/models/v1_node_condition.py index d98f30181b..dd4c377a2a 100644 --- a/kubernetes/aio/client/models/v1_node_condition.py +++ b/kubernetes/aio/client/models/v1_node_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_config_source.py b/kubernetes/aio/client/models/v1_node_config_source.py index 4daef83ef7..01241d8b60 100644 --- a/kubernetes/aio/client/models/v1_node_config_source.py +++ b/kubernetes/aio/client/models/v1_node_config_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeConfigSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_config_status.py b/kubernetes/aio/client/models/v1_node_config_status.py index 0b5f90bc92..47bd87953c 100644 --- a/kubernetes/aio/client/models/v1_node_config_status.py +++ b/kubernetes/aio/client/models/v1_node_config_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeConfigStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_daemon_endpoints.py b/kubernetes/aio/client/models/v1_node_daemon_endpoints.py index 97d573a104..b76a8f0227 100644 --- a/kubernetes/aio/client/models/v1_node_daemon_endpoints.py +++ b/kubernetes/aio/client/models/v1_node_daemon_endpoints.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeDaemonEndpoints(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_features.py b/kubernetes/aio/client/models/v1_node_features.py index 7ad62bd8d3..970fbb5ad0 100644 --- a/kubernetes/aio/client/models/v1_node_features.py +++ b/kubernetes/aio/client/models/v1_node_features.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeFeatures(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_list.py b/kubernetes/aio/client/models/v1_node_list.py index 05d8f25abf..2a516419fd 100644 --- a/kubernetes/aio/client/models/v1_node_list.py +++ b/kubernetes/aio/client/models/v1_node_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_pod_preemption_policy.py b/kubernetes/aio/client/models/v1_node_pod_preemption_policy.py index 9dd5a8ae37..a1d0dc4887 100644 --- a/kubernetes/aio/client/models/v1_node_pod_preemption_policy.py +++ b/kubernetes/aio/client/models/v1_node_pod_preemption_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodePodPreemptionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_runtime_handler.py b/kubernetes/aio/client/models/v1_node_runtime_handler.py index ac7b5b0715..ad93807207 100644 --- a/kubernetes/aio/client/models/v1_node_runtime_handler.py +++ b/kubernetes/aio/client/models/v1_node_runtime_handler.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeRuntimeHandler(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_runtime_handler_features.py b/kubernetes/aio/client/models/v1_node_runtime_handler_features.py index 666d5844a8..1cf35d272f 100644 --- a/kubernetes/aio/client/models/v1_node_runtime_handler_features.py +++ b/kubernetes/aio/client/models/v1_node_runtime_handler_features.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeRuntimeHandlerFeatures(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_selector.py b/kubernetes/aio/client/models/v1_node_selector.py index 25f01d6e77..33f78b781b 100644 --- a/kubernetes/aio/client/models/v1_node_selector.py +++ b/kubernetes/aio/client/models/v1_node_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_selector_requirement.py b/kubernetes/aio/client/models/v1_node_selector_requirement.py index 47844421ef..8076335520 100644 --- a/kubernetes/aio/client/models/v1_node_selector_requirement.py +++ b/kubernetes/aio/client/models/v1_node_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelectorRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_selector_term.py b/kubernetes/aio/client/models/v1_node_selector_term.py index e566a45b0c..b3395c8c5f 100644 --- a/kubernetes/aio/client/models/v1_node_selector_term.py +++ b/kubernetes/aio/client/models/v1_node_selector_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelectorTerm(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_spec.py b/kubernetes/aio/client/models/v1_node_spec.py index 007103862f..9203e09986 100644 --- a/kubernetes/aio/client/models/v1_node_spec.py +++ b/kubernetes/aio/client/models/v1_node_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_status.py b/kubernetes/aio/client/models/v1_node_status.py index 432d9b8cb0..0a7f3200e0 100644 --- a/kubernetes/aio/client/models/v1_node_status.py +++ b/kubernetes/aio/client/models/v1_node_status.py @@ -34,72 +34,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_swap_status.py b/kubernetes/aio/client/models/v1_node_swap_status.py index 5301d42d2d..e782620dd2 100644 --- a/kubernetes/aio/client/models/v1_node_swap_status.py +++ b/kubernetes/aio/client/models/v1_node_swap_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSwapStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_node_system_info.py b/kubernetes/aio/client/models/v1_node_system_info.py index 79cd8ee3a5..907afd472d 100644 --- a/kubernetes/aio/client/models/v1_node_system_info.py +++ b/kubernetes/aio/client/models/v1_node_system_info.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSystemInfo(BaseModel): diff --git a/kubernetes/aio/client/models/v1_non_resource_attributes.py b/kubernetes/aio/client/models/v1_non_resource_attributes.py index cdf351965f..64c39548ef 100644 --- a/kubernetes/aio/client/models/v1_non_resource_attributes.py +++ b/kubernetes/aio/client/models/v1_non_resource_attributes.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourceAttributes(BaseModel): diff --git a/kubernetes/aio/client/models/v1_non_resource_policy_rule.py b/kubernetes/aio/client/models/v1_non_resource_policy_rule.py index f243de1e32..cbda07a3b4 100644 --- a/kubernetes/aio/client/models/v1_non_resource_policy_rule.py +++ b/kubernetes/aio/client/models/v1_non_resource_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourcePolicyRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_non_resource_rule.py b/kubernetes/aio/client/models/v1_non_resource_rule.py index c64996c99c..59dbac6475 100644 --- a/kubernetes/aio/client/models/v1_non_resource_rule.py +++ b/kubernetes/aio/client/models/v1_non_resource_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourceRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_object_field_selector.py b/kubernetes/aio/client/models/v1_object_field_selector.py index 143b0abb8d..75e8bb6b4d 100644 --- a/kubernetes/aio/client/models/v1_object_field_selector.py +++ b/kubernetes/aio/client/models/v1_object_field_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectFieldSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_object_meta.py b/kubernetes/aio/client/models/v1_object_meta.py index 3f70391d27..80e4207bf4 100644 --- a/kubernetes/aio/client/models/v1_object_meta.py +++ b/kubernetes/aio/client/models/v1_object_meta.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectMeta(BaseModel): diff --git a/kubernetes/aio/client/models/v1_object_reference.py b/kubernetes/aio/client/models/v1_object_reference.py index eab24cc2e4..2e839261b3 100644 --- a/kubernetes/aio/client/models/v1_object_reference.py +++ b/kubernetes/aio/client/models/v1_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_opaque_device_configuration.py b/kubernetes/aio/client/models/v1_opaque_device_configuration.py index 365a082743..1d3ebe5e16 100644 --- a/kubernetes/aio/client/models/v1_opaque_device_configuration.py +++ b/kubernetes/aio/client/models/v1_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_overhead.py b/kubernetes/aio/client/models/v1_overhead.py index 9e100d8584..02952fa8dc 100644 --- a/kubernetes/aio/client/models/v1_overhead.py +++ b/kubernetes/aio/client/models/v1_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Overhead(BaseModel): diff --git a/kubernetes/aio/client/models/v1_owner_reference.py b/kubernetes/aio/client/models/v1_owner_reference.py index 2c61aeafb6..11e5ecdd8a 100644 --- a/kubernetes/aio/client/models/v1_owner_reference.py +++ b/kubernetes/aio/client/models/v1_owner_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1OwnerReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_param_kind.py b/kubernetes/aio/client/models/v1_param_kind.py index 32d555a6fd..06f981add7 100644 --- a/kubernetes/aio/client/models/v1_param_kind.py +++ b/kubernetes/aio/client/models/v1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParamKind(BaseModel): diff --git a/kubernetes/aio/client/models/v1_param_ref.py b/kubernetes/aio/client/models/v1_param_ref.py index 5fee504796..a7327243fe 100644 --- a/kubernetes/aio/client/models/v1_param_ref.py +++ b/kubernetes/aio/client/models/v1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParamRef(BaseModel): diff --git a/kubernetes/aio/client/models/v1_parent_reference.py b/kubernetes/aio/client/models/v1_parent_reference.py index f5bc03f8a3..41d0dfabb2 100644 --- a/kubernetes/aio/client/models/v1_parent_reference.py +++ b/kubernetes/aio/client/models/v1_parent_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParentReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume.py b/kubernetes/aio/client/models/v1_persistent_volume.py index 925047ccf1..0d99f0e7ef 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume.py +++ b/kubernetes/aio/client/models/v1_persistent_volume.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolume(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim.py b/kubernetes/aio/client/models/v1_persistent_volume_claim.py index 4a3dd0b9aa..e3d496f542 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_condition.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_condition.py index ccf7f40688..9ef9babb84 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_condition.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_list.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_list.py index a4e79fd678..c15b87d0ed 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_list.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_spec.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_spec.py index d5b766300d..9050a1c482 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_spec.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_status.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_status.py index 5616be2165..6d0fa376a4 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_status.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_template.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_template.py index 570862695d..e5610dcf94 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_template.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_template.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_claim_volume_source.py b/kubernetes/aio/client/models/v1_persistent_volume_claim_volume_source.py index ec31b38a19..fef6ac7107 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_claim_volume_source.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_claim_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_list.py b/kubernetes/aio/client/models/v1_persistent_volume_list.py index c9dc7d5d0e..6424c9e88c 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_list.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_spec.py b/kubernetes/aio/client/models/v1_persistent_volume_spec.py index 038af80c0a..3b4f770324 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_spec.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_spec.py @@ -49,72 +49,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_persistent_volume_status.py b/kubernetes/aio/client/models/v1_persistent_volume_status.py index f66360d971..04c75939fc 100644 --- a/kubernetes/aio/client/models/v1_persistent_volume_status.py +++ b/kubernetes/aio/client/models/v1_persistent_volume_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_photon_persistent_disk_volume_source.py b/kubernetes/aio/client/models/v1_photon_persistent_disk_volume_source.py index 311fe31e4c..e9eaa1ed84 100644 --- a/kubernetes/aio/client/models/v1_photon_persistent_disk_volume_source.py +++ b/kubernetes/aio/client/models/v1_photon_persistent_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PhotonPersistentDiskVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod.py b/kubernetes/aio/client/models/v1_pod.py index 2404210c36..5c1588a7c4 100644 --- a/kubernetes/aio/client/models/v1_pod.py +++ b/kubernetes/aio/client/models/v1_pod.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Pod(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_affinity.py b/kubernetes/aio/client/models/v1_pod_affinity.py index a65eeaad15..64abf59f23 100644 --- a/kubernetes/aio/client/models/v1_pod_affinity.py +++ b/kubernetes/aio/client/models/v1_pod_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAffinity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_affinity_term.py b/kubernetes/aio/client/models/v1_pod_affinity_term.py index 7483898194..3cf5d109c4 100644 --- a/kubernetes/aio/client/models/v1_pod_affinity_term.py +++ b/kubernetes/aio/client/models/v1_pod_affinity_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAffinityTerm(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_anti_affinity.py b/kubernetes/aio/client/models/v1_pod_anti_affinity.py index ef9cb258b8..90e2820c29 100644 --- a/kubernetes/aio/client/models/v1_pod_anti_affinity.py +++ b/kubernetes/aio/client/models/v1_pod_anti_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAntiAffinity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_certificate_projection.py b/kubernetes/aio/client/models/v1_pod_certificate_projection.py index cef38ce24c..d331256f1e 100644 --- a/kubernetes/aio/client/models/v1_pod_certificate_projection.py +++ b/kubernetes/aio/client/models/v1_pod_certificate_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_certificate_request.py b/kubernetes/aio/client/models/v1_pod_certificate_request.py index 93b2e30e01..cca21f39af 100644 --- a/kubernetes/aio/client/models/v1_pod_certificate_request.py +++ b/kubernetes/aio/client/models/v1_pod_certificate_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_certificate_request_list.py b/kubernetes/aio/client/models/v1_pod_certificate_request_list.py index 2f2c0990da..2f887f88d7 100644 --- a/kubernetes/aio/client/models/v1_pod_certificate_request_list.py +++ b/kubernetes/aio/client/models/v1_pod_certificate_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_certificate_request_spec.py b/kubernetes/aio/client/models/v1_pod_certificate_request_spec.py index 281302e499..30da7f6013 100644 --- a/kubernetes/aio/client/models/v1_pod_certificate_request_spec.py +++ b/kubernetes/aio/client/models/v1_pod_certificate_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_certificate_request_status.py b/kubernetes/aio/client/models/v1_pod_certificate_request_status.py index c7c6bfdca2..fd82e07c79 100644 --- a/kubernetes/aio/client/models/v1_pod_certificate_request_status.py +++ b/kubernetes/aio/client/models/v1_pod_certificate_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_condition.py b/kubernetes/aio/client/models/v1_pod_condition.py index e583481c80..e156f8ba15 100644 --- a/kubernetes/aio/client/models/v1_pod_condition.py +++ b/kubernetes/aio/client/models/v1_pod_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_disruption_budget.py b/kubernetes/aio/client/models/v1_pod_disruption_budget.py index 93973fe4fd..93b8212f06 100644 --- a/kubernetes/aio/client/models/v1_pod_disruption_budget.py +++ b/kubernetes/aio/client/models/v1_pod_disruption_budget.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudget(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_disruption_budget_list.py b/kubernetes/aio/client/models/v1_pod_disruption_budget_list.py index 8ab1427443..b841e10bb4 100644 --- a/kubernetes/aio/client/models/v1_pod_disruption_budget_list.py +++ b/kubernetes/aio/client/models/v1_pod_disruption_budget_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_disruption_budget_spec.py b/kubernetes/aio/client/models/v1_pod_disruption_budget_spec.py index 431f2c4ecf..c8b1472489 100644 --- a/kubernetes/aio/client/models/v1_pod_disruption_budget_spec.py +++ b/kubernetes/aio/client/models/v1_pod_disruption_budget_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_disruption_budget_status.py b/kubernetes/aio/client/models/v1_pod_disruption_budget_status.py index f0576ae53c..554cbaefdb 100644 --- a/kubernetes/aio/client/models/v1_pod_disruption_budget_status.py +++ b/kubernetes/aio/client/models/v1_pod_disruption_budget_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_dns_config.py b/kubernetes/aio/client/models/v1_pod_dns_config.py index b7dc3c5832..252d02d701 100644 --- a/kubernetes/aio/client/models/v1_pod_dns_config.py +++ b/kubernetes/aio/client/models/v1_pod_dns_config.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDNSConfig(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_dns_config_option.py b/kubernetes/aio/client/models/v1_pod_dns_config_option.py index 9423e570fa..9a73ce7cc1 100644 --- a/kubernetes/aio/client/models/v1_pod_dns_config_option.py +++ b/kubernetes/aio/client/models/v1_pod_dns_config_option.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDNSConfigOption(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_extended_resource_claim_status.py b/kubernetes/aio/client/models/v1_pod_extended_resource_claim_status.py index ad4144e75a..b85bd75d8c 100644 --- a/kubernetes/aio/client/models/v1_pod_extended_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1_pod_extended_resource_claim_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodExtendedResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_failure_policy.py b/kubernetes/aio/client/models/v1_pod_failure_policy.py index 6a91634c81..6176c5417a 100644 --- a/kubernetes/aio/client/models/v1_pod_failure_policy.py +++ b/kubernetes/aio/client/models/v1_pod_failure_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py b/kubernetes/aio/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py index 0210056405..cf279cd47e 100644 --- a/kubernetes/aio/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py +++ b/kubernetes/aio/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyOnExitCodesRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py b/kubernetes/aio/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py index 459bcd9b5f..4b65a9e6be 100644 --- a/kubernetes/aio/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py +++ b/kubernetes/aio/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyOnPodConditionsPattern(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_failure_policy_rule.py b/kubernetes/aio/client/models/v1_pod_failure_policy_rule.py index ef8c270d83..4da3ee4c45 100644 --- a/kubernetes/aio/client/models/v1_pod_failure_policy_rule.py +++ b/kubernetes/aio/client/models/v1_pod_failure_policy_rule.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_ip.py b/kubernetes/aio/client/models/v1_pod_ip.py index 5b42a636ec..6c746ebed4 100644 --- a/kubernetes/aio/client/models/v1_pod_ip.py +++ b/kubernetes/aio/client/models/v1_pod_ip.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodIP(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_list.py b/kubernetes/aio/client/models/v1_pod_list.py index 8f1fb4c51e..c92a86d658 100644 --- a/kubernetes/aio/client/models/v1_pod_list.py +++ b/kubernetes/aio/client/models/v1_pod_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_os.py b/kubernetes/aio/client/models/v1_pod_os.py index 61338f7806..44d4eb00b7 100644 --- a/kubernetes/aio/client/models/v1_pod_os.py +++ b/kubernetes/aio/client/models/v1_pod_os.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodOS(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_readiness_gate.py b/kubernetes/aio/client/models/v1_pod_readiness_gate.py index f9e84a1dd6..a6c3f82538 100644 --- a/kubernetes/aio/client/models/v1_pod_readiness_gate.py +++ b/kubernetes/aio/client/models/v1_pod_readiness_gate.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodReadinessGate(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_resource_claim.py b/kubernetes/aio/client/models/v1_pod_resource_claim.py index 26122ed300..649492bde4 100644 --- a/kubernetes/aio/client/models/v1_pod_resource_claim.py +++ b/kubernetes/aio/client/models/v1_pod_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_resource_claim_status.py b/kubernetes/aio/client/models/v1_pod_resource_claim_status.py index abac45c06f..cf0efff23b 100644 --- a/kubernetes/aio/client/models/v1_pod_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1_pod_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_scheduling_gate.py b/kubernetes/aio/client/models/v1_pod_scheduling_gate.py index f33128a719..56ee60d7d0 100644 --- a/kubernetes/aio/client/models/v1_pod_scheduling_gate.py +++ b/kubernetes/aio/client/models/v1_pod_scheduling_gate.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSchedulingGate(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_scheduling_group.py b/kubernetes/aio/client/models/v1_pod_scheduling_group.py index 651fe39523..f6c10b6b6b 100644 --- a/kubernetes/aio/client/models/v1_pod_scheduling_group.py +++ b/kubernetes/aio/client/models/v1_pod_scheduling_group.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSchedulingGroup(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_security_context.py b/kubernetes/aio/client/models/v1_pod_security_context.py index e5bb67796b..3febb0bab6 100644 --- a/kubernetes/aio/client/models/v1_pod_security_context.py +++ b/kubernetes/aio/client/models/v1_pod_security_context.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSecurityContext(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_spec.py b/kubernetes/aio/client/models/v1_pod_spec.py index 36b4a6c098..e57a90673f 100644 --- a/kubernetes/aio/client/models/v1_pod_spec.py +++ b/kubernetes/aio/client/models/v1_pod_spec.py @@ -42,72 +42,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_status.py b/kubernetes/aio/client/models/v1_pod_status.py index 6f65ca8c11..adc1e8a427 100644 --- a/kubernetes/aio/client/models/v1_pod_status.py +++ b/kubernetes/aio/client/models/v1_pod_status.py @@ -35,72 +35,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_template.py b/kubernetes/aio/client/models/v1_pod_template.py index 6a786e2617..fc7411cc2f 100644 --- a/kubernetes/aio/client/models/v1_pod_template.py +++ b/kubernetes/aio/client/models/v1_pod_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_template_list.py b/kubernetes/aio/client/models/v1_pod_template_list.py index a4b88d12f7..371db001ab 100644 --- a/kubernetes/aio/client/models/v1_pod_template_list.py +++ b/kubernetes/aio/client/models/v1_pod_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_template_spec.py b/kubernetes/aio/client/models/v1_pod_template_spec.py index 4eb45e0fd0..7ea7e3d1dd 100644 --- a/kubernetes/aio/client/models/v1_pod_template_spec.py +++ b/kubernetes/aio/client/models/v1_pod_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_pod_volume_health.py b/kubernetes/aio/client/models/v1_pod_volume_health.py index fa36bea046..4ebd7d1844 100644 --- a/kubernetes/aio/client/models/v1_pod_volume_health.py +++ b/kubernetes/aio/client/models/v1_pod_volume_health.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodVolumeHealth(BaseModel): diff --git a/kubernetes/aio/client/models/v1_policy_rule.py b/kubernetes/aio/client/models/v1_policy_rule.py index f56df5a070..f52be278c2 100644 --- a/kubernetes/aio/client/models/v1_policy_rule.py +++ b/kubernetes/aio/client/models/v1_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PolicyRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_policy_rules_with_subjects.py b/kubernetes/aio/client/models/v1_policy_rules_with_subjects.py index 81384dd08c..37de66e30a 100644 --- a/kubernetes/aio/client/models/v1_policy_rules_with_subjects.py +++ b/kubernetes/aio/client/models/v1_policy_rules_with_subjects.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PolicyRulesWithSubjects(BaseModel): diff --git a/kubernetes/aio/client/models/v1_port_status.py b/kubernetes/aio/client/models/v1_port_status.py index ef18c7f023..b625f24fb2 100644 --- a/kubernetes/aio/client/models/v1_port_status.py +++ b/kubernetes/aio/client/models/v1_port_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PortStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_portworx_volume_source.py b/kubernetes/aio/client/models/v1_portworx_volume_source.py index df1e32333c..42916425d3 100644 --- a/kubernetes/aio/client/models/v1_portworx_volume_source.py +++ b/kubernetes/aio/client/models/v1_portworx_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PortworxVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_preconditions.py b/kubernetes/aio/client/models/v1_preconditions.py index 464be0f68b..52a8ccfca8 100644 --- a/kubernetes/aio/client/models/v1_preconditions.py +++ b/kubernetes/aio/client/models/v1_preconditions.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Preconditions(BaseModel): diff --git a/kubernetes/aio/client/models/v1_preferred_scheduling_term.py b/kubernetes/aio/client/models/v1_preferred_scheduling_term.py index 5e738c2ef6..57b84d5c4d 100644 --- a/kubernetes/aio/client/models/v1_preferred_scheduling_term.py +++ b/kubernetes/aio/client/models/v1_preferred_scheduling_term.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PreferredSchedulingTerm(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_class.py b/kubernetes/aio/client/models/v1_priority_class.py index 2a280c634c..1bf5b46535 100644 --- a/kubernetes/aio/client/models/v1_priority_class.py +++ b/kubernetes/aio/client/models/v1_priority_class.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_class_list.py b/kubernetes/aio/client/models/v1_priority_class_list.py index 3d6d2e6d10..d0821b617b 100644 --- a/kubernetes/aio/client/models/v1_priority_class_list.py +++ b/kubernetes/aio/client/models/v1_priority_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration.py b/kubernetes/aio/client/models/v1_priority_level_configuration.py index 43d3e6bb34..a2b7b46fc0 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration_condition.py b/kubernetes/aio/client/models/v1_priority_level_configuration_condition.py index c99da95a13..c9144c254f 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration_condition.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration_list.py b/kubernetes/aio/client/models/v1_priority_level_configuration_list.py index 173440df31..ec13f3f958 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration_list.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration_reference.py b/kubernetes/aio/client/models/v1_priority_level_configuration_reference.py index 22e52bf36a..a05ccfcbad 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration_reference.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration_spec.py b/kubernetes/aio/client/models/v1_priority_level_configuration_spec.py index 200c04cd03..98a0b6885e 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration_spec.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_priority_level_configuration_status.py b/kubernetes/aio/client/models/v1_priority_level_configuration_status.py index df758125a8..0655275646 100644 --- a/kubernetes/aio/client/models/v1_priority_level_configuration_status.py +++ b/kubernetes/aio/client/models/v1_priority_level_configuration_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_probe.py b/kubernetes/aio/client/models/v1_probe.py index 3ad7a7aa28..46ea991b06 100644 --- a/kubernetes/aio/client/models/v1_probe.py +++ b/kubernetes/aio/client/models/v1_probe.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Probe(BaseModel): diff --git a/kubernetes/aio/client/models/v1_projected_volume_source.py b/kubernetes/aio/client/models/v1_projected_volume_source.py index c60c39bdcb..3f67eb2bdd 100644 --- a/kubernetes/aio/client/models/v1_projected_volume_source.py +++ b/kubernetes/aio/client/models/v1_projected_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ProjectedVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_queuing_configuration.py b/kubernetes/aio/client/models/v1_queuing_configuration.py index 3bf8ee6e2b..ff6f171c6f 100644 --- a/kubernetes/aio/client/models/v1_queuing_configuration.py +++ b/kubernetes/aio/client/models/v1_queuing_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1QueuingConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_quobyte_volume_source.py b/kubernetes/aio/client/models/v1_quobyte_volume_source.py index 1631e7452b..16ce5e556b 100644 --- a/kubernetes/aio/client/models/v1_quobyte_volume_source.py +++ b/kubernetes/aio/client/models/v1_quobyte_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1QuobyteVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rbd_persistent_volume_source.py b/kubernetes/aio/client/models/v1_rbd_persistent_volume_source.py index 404821b283..4d8614e5e5 100644 --- a/kubernetes/aio/client/models/v1_rbd_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_rbd_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RBDPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rbd_volume_source.py b/kubernetes/aio/client/models/v1_rbd_volume_source.py index 44d8714d3d..b098584089 100644 --- a/kubernetes/aio/client/models/v1_rbd_volume_source.py +++ b/kubernetes/aio/client/models/v1_rbd_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RBDVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replica_set.py b/kubernetes/aio/client/models/v1_replica_set.py index c643bf7076..5d87f2ece1 100644 --- a/kubernetes/aio/client/models/v1_replica_set.py +++ b/kubernetes/aio/client/models/v1_replica_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replica_set_condition.py b/kubernetes/aio/client/models/v1_replica_set_condition.py index a64a0300a7..3bf254e5d3 100644 --- a/kubernetes/aio/client/models/v1_replica_set_condition.py +++ b/kubernetes/aio/client/models/v1_replica_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replica_set_list.py b/kubernetes/aio/client/models/v1_replica_set_list.py index f9483f1772..70dccd1cb6 100644 --- a/kubernetes/aio/client/models/v1_replica_set_list.py +++ b/kubernetes/aio/client/models/v1_replica_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replica_set_spec.py b/kubernetes/aio/client/models/v1_replica_set_spec.py index 4ebcc18f57..34546c7740 100644 --- a/kubernetes/aio/client/models/v1_replica_set_spec.py +++ b/kubernetes/aio/client/models/v1_replica_set_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replica_set_status.py b/kubernetes/aio/client/models/v1_replica_set_status.py index 7aabdcb31c..4952b45d04 100644 --- a/kubernetes/aio/client/models/v1_replica_set_status.py +++ b/kubernetes/aio/client/models/v1_replica_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replication_controller.py b/kubernetes/aio/client/models/v1_replication_controller.py index 6cceec9296..817e01f84f 100644 --- a/kubernetes/aio/client/models/v1_replication_controller.py +++ b/kubernetes/aio/client/models/v1_replication_controller.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationController(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replication_controller_condition.py b/kubernetes/aio/client/models/v1_replication_controller_condition.py index 640c824fa5..cc8c705ca4 100644 --- a/kubernetes/aio/client/models/v1_replication_controller_condition.py +++ b/kubernetes/aio/client/models/v1_replication_controller_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replication_controller_list.py b/kubernetes/aio/client/models/v1_replication_controller_list.py index e4bbdf0129..6d712411d5 100644 --- a/kubernetes/aio/client/models/v1_replication_controller_list.py +++ b/kubernetes/aio/client/models/v1_replication_controller_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replication_controller_spec.py b/kubernetes/aio/client/models/v1_replication_controller_spec.py index 1623574122..3d23077e7b 100644 --- a/kubernetes/aio/client/models/v1_replication_controller_spec.py +++ b/kubernetes/aio/client/models/v1_replication_controller_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_replication_controller_status.py b/kubernetes/aio/client/models/v1_replication_controller_status.py index 2943b24ab2..7cff3581ce 100644 --- a/kubernetes/aio/client/models/v1_replication_controller_status.py +++ b/kubernetes/aio/client/models/v1_replication_controller_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_attributes.py b/kubernetes/aio/client/models/v1_resource_attributes.py index cfd18cec1b..ce54414ed2 100644 --- a/kubernetes/aio/client/models/v1_resource_attributes.py +++ b/kubernetes/aio/client/models/v1_resource_attributes.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceAttributes(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_consumer_reference.py b/kubernetes/aio/client/models/v1_resource_claim_consumer_reference.py index 8909a0a879..d6bb0091cd 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_consumer_reference.py +++ b/kubernetes/aio/client/models/v1_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_list.py b/kubernetes/aio/client/models/v1_resource_claim_list.py index bd6b5d3207..82201d270e 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_list.py +++ b/kubernetes/aio/client/models/v1_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_spec.py b/kubernetes/aio/client/models/v1_resource_claim_spec.py index 7c9188e53a..72b622e61e 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_spec.py +++ b/kubernetes/aio/client/models/v1_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_status.py b/kubernetes/aio/client/models/v1_resource_claim_status.py index 8a67e49c28..f8652ce135 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_template.py b/kubernetes/aio/client/models/v1_resource_claim_template.py index 0b7d782328..d197756298 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_template.py +++ b/kubernetes/aio/client/models/v1_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_template_list.py b/kubernetes/aio/client/models/v1_resource_claim_template_list.py index ad4e08074e..c061af4453 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_template_list.py +++ b/kubernetes/aio/client/models/v1_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_claim_template_spec.py b/kubernetes/aio/client/models/v1_resource_claim_template_spec.py index a9f3202c50..c74de45198 100644 --- a/kubernetes/aio/client/models/v1_resource_claim_template_spec.py +++ b/kubernetes/aio/client/models/v1_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_field_selector.py b/kubernetes/aio/client/models/v1_resource_field_selector.py index 4c8ff82c36..b30a53ba78 100644 --- a/kubernetes/aio/client/models/v1_resource_field_selector.py +++ b/kubernetes/aio/client/models/v1_resource_field_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceFieldSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_health.py b/kubernetes/aio/client/models/v1_resource_health.py index 1f5c3ecf0e..60d07b3c05 100644 --- a/kubernetes/aio/client/models/v1_resource_health.py +++ b/kubernetes/aio/client/models/v1_resource_health.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceHealth(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_policy_rule.py b/kubernetes/aio/client/models/v1_resource_policy_rule.py index a2075c8d8a..74343ca48f 100644 --- a/kubernetes/aio/client/models/v1_resource_policy_rule.py +++ b/kubernetes/aio/client/models/v1_resource_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourcePolicyRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_pool.py b/kubernetes/aio/client/models/v1_resource_pool.py index 4f7a43c136..026da6fb30 100644 --- a/kubernetes/aio/client/models/v1_resource_pool.py +++ b/kubernetes/aio/client/models/v1_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourcePool(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_quota.py b/kubernetes/aio/client/models/v1_resource_quota.py index 3e2d4db1e8..c33601d592 100644 --- a/kubernetes/aio/client/models/v1_resource_quota.py +++ b/kubernetes/aio/client/models/v1_resource_quota.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuota(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_quota_list.py b/kubernetes/aio/client/models/v1_resource_quota_list.py index c5c7c69b13..b7bb5d54d1 100644 --- a/kubernetes/aio/client/models/v1_resource_quota_list.py +++ b/kubernetes/aio/client/models/v1_resource_quota_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_quota_spec.py b/kubernetes/aio/client/models/v1_resource_quota_spec.py index a66cda1d78..1267cfe282 100644 --- a/kubernetes/aio/client/models/v1_resource_quota_spec.py +++ b/kubernetes/aio/client/models/v1_resource_quota_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_quota_status.py b/kubernetes/aio/client/models/v1_resource_quota_status.py index a170899577..14f21aa51a 100644 --- a/kubernetes/aio/client/models/v1_resource_quota_status.py +++ b/kubernetes/aio/client/models/v1_resource_quota_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_requirements.py b/kubernetes/aio/client/models/v1_resource_requirements.py index 3f8ea9cf60..e7444a0c1d 100644 --- a/kubernetes/aio/client/models/v1_resource_requirements.py +++ b/kubernetes/aio/client/models/v1_resource_requirements.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceRequirements(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_rule.py b/kubernetes/aio/client/models/v1_resource_rule.py index c18e371291..a8fd225494 100644 --- a/kubernetes/aio/client/models/v1_resource_rule.py +++ b/kubernetes/aio/client/models/v1_resource_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_slice.py b/kubernetes/aio/client/models/v1_resource_slice.py index d56e0bcfac..2b1b62d08a 100644 --- a/kubernetes/aio/client/models/v1_resource_slice.py +++ b/kubernetes/aio/client/models/v1_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSlice(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_slice_list.py b/kubernetes/aio/client/models/v1_resource_slice_list.py index b555d9988f..8ef171fff6 100644 --- a/kubernetes/aio/client/models/v1_resource_slice_list.py +++ b/kubernetes/aio/client/models/v1_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSliceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_slice_spec.py b/kubernetes/aio/client/models/v1_resource_slice_spec.py index 058c339597..b048b41eba 100644 --- a/kubernetes/aio/client/models/v1_resource_slice_spec.py +++ b/kubernetes/aio/client/models/v1_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSliceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_resource_status.py b/kubernetes/aio/client/models/v1_resource_status.py index e7f08952d3..905839dbd3 100644 --- a/kubernetes/aio/client/models/v1_resource_status.py +++ b/kubernetes/aio/client/models/v1_resource_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_role.py b/kubernetes/aio/client/models/v1_role.py index 699500b918..207c64e6a8 100644 --- a/kubernetes/aio/client/models/v1_role.py +++ b/kubernetes/aio/client/models/v1_role.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Role(BaseModel): diff --git a/kubernetes/aio/client/models/v1_role_binding.py b/kubernetes/aio/client/models/v1_role_binding.py index 6ab07d991b..620fcdbcd6 100644 --- a/kubernetes/aio/client/models/v1_role_binding.py +++ b/kubernetes/aio/client/models/v1_role_binding.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1_role_binding_list.py b/kubernetes/aio/client/models/v1_role_binding_list.py index e3179e58ac..ae4ebe34db 100644 --- a/kubernetes/aio/client/models/v1_role_binding_list.py +++ b/kubernetes/aio/client/models/v1_role_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_role_list.py b/kubernetes/aio/client/models/v1_role_list.py index 650fb92a7c..f46bfae2f5 100644 --- a/kubernetes/aio/client/models/v1_role_list.py +++ b/kubernetes/aio/client/models/v1_role_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_role_ref.py b/kubernetes/aio/client/models/v1_role_ref.py index f795fe539d..a74984597b 100644 --- a/kubernetes/aio/client/models/v1_role_ref.py +++ b/kubernetes/aio/client/models/v1_role_ref.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleRef(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rolling_update_daemon_set.py b/kubernetes/aio/client/models/v1_rolling_update_daemon_set.py index b5c84a2cc4..6e8005570d 100644 --- a/kubernetes/aio/client/models/v1_rolling_update_daemon_set.py +++ b/kubernetes/aio/client/models/v1_rolling_update_daemon_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateDaemonSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rolling_update_deployment.py b/kubernetes/aio/client/models/v1_rolling_update_deployment.py index 706e494e2b..4a2bdd0ee6 100644 --- a/kubernetes/aio/client/models/v1_rolling_update_deployment.py +++ b/kubernetes/aio/client/models/v1_rolling_update_deployment.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateDeployment(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rolling_update_stateful_set_strategy.py b/kubernetes/aio/client/models/v1_rolling_update_stateful_set_strategy.py index ab2c7ce46f..bc0b3a7f67 100644 --- a/kubernetes/aio/client/models/v1_rolling_update_stateful_set_strategy.py +++ b/kubernetes/aio/client/models/v1_rolling_update_stateful_set_strategy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateStatefulSetStrategy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_rule_with_operations.py b/kubernetes/aio/client/models/v1_rule_with_operations.py index a8919e828a..4082592751 100644 --- a/kubernetes/aio/client/models/v1_rule_with_operations.py +++ b/kubernetes/aio/client/models/v1_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuleWithOperations(BaseModel): diff --git a/kubernetes/aio/client/models/v1_runtime_class.py b/kubernetes/aio/client/models/v1_runtime_class.py index 538e8d772e..fa1bd4910a 100644 --- a/kubernetes/aio/client/models/v1_runtime_class.py +++ b/kubernetes/aio/client/models/v1_runtime_class.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuntimeClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_runtime_class_list.py b/kubernetes/aio/client/models/v1_runtime_class_list.py index 57b4db9d68..6c14a8ff66 100644 --- a/kubernetes/aio/client/models/v1_runtime_class_list.py +++ b/kubernetes/aio/client/models/v1_runtime_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuntimeClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scale.py b/kubernetes/aio/client/models/v1_scale.py index 599d8104a9..ba088fb386 100644 --- a/kubernetes/aio/client/models/v1_scale.py +++ b/kubernetes/aio/client/models/v1_scale.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Scale(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scale_io_persistent_volume_source.py b/kubernetes/aio/client/models/v1_scale_io_persistent_volume_source.py index ccc065a1f4..b25da3d736 100644 --- a/kubernetes/aio/client/models/v1_scale_io_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_scale_io_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleIOPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scale_io_volume_source.py b/kubernetes/aio/client/models/v1_scale_io_volume_source.py index 9da370948e..245dbf661e 100644 --- a/kubernetes/aio/client/models/v1_scale_io_volume_source.py +++ b/kubernetes/aio/client/models/v1_scale_io_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleIOVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scale_spec.py b/kubernetes/aio/client/models/v1_scale_spec.py index 6908e005b3..33c581ee15 100644 --- a/kubernetes/aio/client/models/v1_scale_spec.py +++ b/kubernetes/aio/client/models/v1_scale_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scale_status.py b/kubernetes/aio/client/models/v1_scale_status.py index 043ee818dd..3a6c938f46 100644 --- a/kubernetes/aio/client/models/v1_scale_status.py +++ b/kubernetes/aio/client/models/v1_scale_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scheduling.py b/kubernetes/aio/client/models/v1_scheduling.py index a571304b64..064f1a4ea4 100644 --- a/kubernetes/aio/client/models/v1_scheduling.py +++ b/kubernetes/aio/client/models/v1_scheduling.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Scheduling(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scope_selector.py b/kubernetes/aio/client/models/v1_scope_selector.py index bb65e504cf..c54050992d 100644 --- a/kubernetes/aio/client/models/v1_scope_selector.py +++ b/kubernetes/aio/client/models/v1_scope_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScopeSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_scoped_resource_selector_requirement.py b/kubernetes/aio/client/models/v1_scoped_resource_selector_requirement.py index e7a67ac25c..6f1d8b550a 100644 --- a/kubernetes/aio/client/models/v1_scoped_resource_selector_requirement.py +++ b/kubernetes/aio/client/models/v1_scoped_resource_selector_requirement.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScopedResourceSelectorRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_se_linux_options.py b/kubernetes/aio/client/models/v1_se_linux_options.py index 3a76a3ec8d..a98dfa3a8f 100644 --- a/kubernetes/aio/client/models/v1_se_linux_options.py +++ b/kubernetes/aio/client/models/v1_se_linux_options.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SELinuxOptions(BaseModel): diff --git a/kubernetes/aio/client/models/v1_seccomp_profile.py b/kubernetes/aio/client/models/v1_seccomp_profile.py index b531095416..754192f08b 100644 --- a/kubernetes/aio/client/models/v1_seccomp_profile.py +++ b/kubernetes/aio/client/models/v1_seccomp_profile.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SeccompProfile(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret.py b/kubernetes/aio/client/models/v1_secret.py index 4b22c76015..dda65a3997 100644 --- a/kubernetes/aio/client/models/v1_secret.py +++ b/kubernetes/aio/client/models/v1_secret.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Secret(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_env_source.py b/kubernetes/aio/client/models/v1_secret_env_source.py index 7cff1f38b2..b497cdd178 100644 --- a/kubernetes/aio/client/models/v1_secret_env_source.py +++ b/kubernetes/aio/client/models/v1_secret_env_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretEnvSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_key_selector.py b/kubernetes/aio/client/models/v1_secret_key_selector.py index 2c3a8e6c1e..15a226b109 100644 --- a/kubernetes/aio/client/models/v1_secret_key_selector.py +++ b/kubernetes/aio/client/models/v1_secret_key_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretKeySelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_list.py b/kubernetes/aio/client/models/v1_secret_list.py index efe8a151f1..afad5a4421 100644 --- a/kubernetes/aio/client/models/v1_secret_list.py +++ b/kubernetes/aio/client/models/v1_secret_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_projection.py b/kubernetes/aio/client/models/v1_secret_projection.py index b27eac5061..699fb4e454 100644 --- a/kubernetes/aio/client/models/v1_secret_projection.py +++ b/kubernetes/aio/client/models/v1_secret_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_reference.py b/kubernetes/aio/client/models/v1_secret_reference.py index e67fc9ec1c..6b3f4640f4 100644 --- a/kubernetes/aio/client/models/v1_secret_reference.py +++ b/kubernetes/aio/client/models/v1_secret_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_secret_volume_source.py b/kubernetes/aio/client/models/v1_secret_volume_source.py index b7d34f31a1..f48727f91c 100644 --- a/kubernetes/aio/client/models/v1_secret_volume_source.py +++ b/kubernetes/aio/client/models/v1_secret_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_security_context.py b/kubernetes/aio/client/models/v1_security_context.py index df30fc65cc..94e8dec7f4 100644 --- a/kubernetes/aio/client/models/v1_security_context.py +++ b/kubernetes/aio/client/models/v1_security_context.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecurityContext(BaseModel): diff --git a/kubernetes/aio/client/models/v1_selectable_field.py b/kubernetes/aio/client/models/v1_selectable_field.py index c764f79825..129ac18ee5 100644 --- a/kubernetes/aio/client/models/v1_selectable_field.py +++ b/kubernetes/aio/client/models/v1_selectable_field.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelectableField(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_access_review.py b/kubernetes/aio/client/models/v1_self_subject_access_review.py index ef3bfeea6a..c6dd6247c7 100644 --- a/kubernetes/aio/client/models/v1_self_subject_access_review.py +++ b/kubernetes/aio/client/models/v1_self_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectAccessReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_access_review_spec.py b/kubernetes/aio/client/models/v1_self_subject_access_review_spec.py index 9c9d387dfe..fd6cfb3456 100644 --- a/kubernetes/aio/client/models/v1_self_subject_access_review_spec.py +++ b/kubernetes/aio/client/models/v1_self_subject_access_review_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectAccessReviewSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_review.py b/kubernetes/aio/client/models/v1_self_subject_review.py index 0235996b93..68ac96fa84 100644 --- a/kubernetes/aio/client/models/v1_self_subject_review.py +++ b/kubernetes/aio/client/models/v1_self_subject_review.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_review_status.py b/kubernetes/aio/client/models/v1_self_subject_review_status.py index 1edfaf11ea..b6c268696a 100644 --- a/kubernetes/aio/client/models/v1_self_subject_review_status.py +++ b/kubernetes/aio/client/models/v1_self_subject_review_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectReviewStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_rules_review.py b/kubernetes/aio/client/models/v1_self_subject_rules_review.py index 1dff3f0951..773335b870 100644 --- a/kubernetes/aio/client/models/v1_self_subject_rules_review.py +++ b/kubernetes/aio/client/models/v1_self_subject_rules_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectRulesReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_self_subject_rules_review_spec.py b/kubernetes/aio/client/models/v1_self_subject_rules_review_spec.py index eaa8a036b7..f92a9f2a63 100644 --- a/kubernetes/aio/client/models/v1_self_subject_rules_review_spec.py +++ b/kubernetes/aio/client/models/v1_self_subject_rules_review_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectRulesReviewSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_server_address_by_client_cidr.py b/kubernetes/aio/client/models/v1_server_address_by_client_cidr.py index e556be1eda..ce54a76856 100644 --- a/kubernetes/aio/client/models/v1_server_address_by_client_cidr.py +++ b/kubernetes/aio/client/models/v1_server_address_by_client_cidr.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServerAddressByClientCIDR(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service.py b/kubernetes/aio/client/models/v1_service.py index bd3c19f7fc..5a7c8aad33 100644 --- a/kubernetes/aio/client/models/v1_service.py +++ b/kubernetes/aio/client/models/v1_service.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Service(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_account.py b/kubernetes/aio/client/models/v1_service_account.py index a599ab476f..dd236c72b7 100644 --- a/kubernetes/aio/client/models/v1_service_account.py +++ b/kubernetes/aio/client/models/v1_service_account.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccount(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_account_list.py b/kubernetes/aio/client/models/v1_service_account_list.py index 292d1709e0..2445398794 100644 --- a/kubernetes/aio/client/models/v1_service_account_list.py +++ b/kubernetes/aio/client/models/v1_service_account_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_account_subject.py b/kubernetes/aio/client/models/v1_service_account_subject.py index 4c2364d615..735aa10284 100644 --- a/kubernetes/aio/client/models/v1_service_account_subject.py +++ b/kubernetes/aio/client/models/v1_service_account_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountSubject(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_account_token_projection.py b/kubernetes/aio/client/models/v1_service_account_token_projection.py index ca757d2b21..fd7337d0a9 100644 --- a/kubernetes/aio/client/models/v1_service_account_token_projection.py +++ b/kubernetes/aio/client/models/v1_service_account_token_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountTokenProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_backend_port.py b/kubernetes/aio/client/models/v1_service_backend_port.py index 3777a294bb..15f595fd3e 100644 --- a/kubernetes/aio/client/models/v1_service_backend_port.py +++ b/kubernetes/aio/client/models/v1_service_backend_port.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceBackendPort(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_cidr.py b/kubernetes/aio/client/models/v1_service_cidr.py index d104f7448d..50a2baf01e 100644 --- a/kubernetes/aio/client/models/v1_service_cidr.py +++ b/kubernetes/aio/client/models/v1_service_cidr.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDR(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_cidr_list.py b/kubernetes/aio/client/models/v1_service_cidr_list.py index 9890811226..f7feb00408 100644 --- a/kubernetes/aio/client/models/v1_service_cidr_list.py +++ b/kubernetes/aio/client/models/v1_service_cidr_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_cidr_spec.py b/kubernetes/aio/client/models/v1_service_cidr_spec.py index 9ae607d7d5..27fb5cdb8f 100644 --- a/kubernetes/aio/client/models/v1_service_cidr_spec.py +++ b/kubernetes/aio/client/models/v1_service_cidr_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_cidr_status.py b/kubernetes/aio/client/models/v1_service_cidr_status.py index 170dbe8997..fad53a9144 100644 --- a/kubernetes/aio/client/models/v1_service_cidr_status.py +++ b/kubernetes/aio/client/models/v1_service_cidr_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_list.py b/kubernetes/aio/client/models/v1_service_list.py index 9af16cc5f1..f40108adde 100644 --- a/kubernetes/aio/client/models/v1_service_list.py +++ b/kubernetes/aio/client/models/v1_service_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_port.py b/kubernetes/aio/client/models/v1_service_port.py index ba5625f214..b02b3f1005 100644 --- a/kubernetes/aio/client/models/v1_service_port.py +++ b/kubernetes/aio/client/models/v1_service_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServicePort(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_spec.py b/kubernetes/aio/client/models/v1_service_spec.py index 7e849f6cea..68e0eb7808 100644 --- a/kubernetes/aio/client/models/v1_service_spec.py +++ b/kubernetes/aio/client/models/v1_service_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_service_status.py b/kubernetes/aio/client/models/v1_service_status.py index bfff50b066..50f8df503b 100644 --- a/kubernetes/aio/client/models/v1_service_status.py +++ b/kubernetes/aio/client/models/v1_service_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_session_affinity_config.py b/kubernetes/aio/client/models/v1_session_affinity_config.py index 0d1e15fa39..e9ec405a31 100644 --- a/kubernetes/aio/client/models/v1_session_affinity_config.py +++ b/kubernetes/aio/client/models/v1_session_affinity_config.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SessionAffinityConfig(BaseModel): diff --git a/kubernetes/aio/client/models/v1_shard_info.py b/kubernetes/aio/client/models/v1_shard_info.py index c8e9d75e9f..e5b6072eb3 100644 --- a/kubernetes/aio/client/models/v1_shard_info.py +++ b/kubernetes/aio/client/models/v1_shard_info.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ShardInfo(BaseModel): diff --git a/kubernetes/aio/client/models/v1_sleep_action.py b/kubernetes/aio/client/models/v1_sleep_action.py index df6733738e..0a8f2b18ea 100644 --- a/kubernetes/aio/client/models/v1_sleep_action.py +++ b/kubernetes/aio/client/models/v1_sleep_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SleepAction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set.py b/kubernetes/aio/client/models/v1_stateful_set.py index 1e567174b8..3f427e85dc 100644 --- a/kubernetes/aio/client/models/v1_stateful_set.py +++ b/kubernetes/aio/client/models/v1_stateful_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_condition.py b/kubernetes/aio/client/models/v1_stateful_set_condition.py index a223e6d709..e7c7d292be 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_condition.py +++ b/kubernetes/aio/client/models/v1_stateful_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_list.py b/kubernetes/aio/client/models/v1_stateful_set_list.py index 6111946321..de2a9aee15 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_list.py +++ b/kubernetes/aio/client/models/v1_stateful_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_ordinals.py b/kubernetes/aio/client/models/v1_stateful_set_ordinals.py index 115fdd2332..ec05705ded 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_ordinals.py +++ b/kubernetes/aio/client/models/v1_stateful_set_ordinals.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetOrdinals(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py b/kubernetes/aio/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py index e0de442c50..cdd4cc0aab 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py +++ b/kubernetes/aio/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetPersistentVolumeClaimRetentionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_spec.py b/kubernetes/aio/client/models/v1_stateful_set_spec.py index 32818efc55..22e31053ea 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_spec.py +++ b/kubernetes/aio/client/models/v1_stateful_set_spec.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_status.py b/kubernetes/aio/client/models/v1_stateful_set_status.py index 7da7b6de9a..6968d98c4e 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_status.py +++ b/kubernetes/aio/client/models/v1_stateful_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_stateful_set_update_strategy.py b/kubernetes/aio/client/models/v1_stateful_set_update_strategy.py index 28431ce961..1df3a74057 100644 --- a/kubernetes/aio/client/models/v1_stateful_set_update_strategy.py +++ b/kubernetes/aio/client/models/v1_stateful_set_update_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetUpdateStrategy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_status.py b/kubernetes/aio/client/models/v1_status.py index f40b66a6c6..13f9f4ae66 100644 --- a/kubernetes/aio/client/models/v1_status.py +++ b/kubernetes/aio/client/models/v1_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Status(BaseModel): diff --git a/kubernetes/aio/client/models/v1_status_cause.py b/kubernetes/aio/client/models/v1_status_cause.py index b72089803a..b3ed9fb52e 100644 --- a/kubernetes/aio/client/models/v1_status_cause.py +++ b/kubernetes/aio/client/models/v1_status_cause.py @@ -26,72 +26,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatusCause(BaseModel): diff --git a/kubernetes/aio/client/models/v1_status_details.py b/kubernetes/aio/client/models/v1_status_details.py index c61b150f40..5af983834d 100644 --- a/kubernetes/aio/client/models/v1_status_details.py +++ b/kubernetes/aio/client/models/v1_status_details.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatusDetails(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_class.py b/kubernetes/aio/client/models/v1_storage_class.py index fa466c7226..c3b1436aa7 100644 --- a/kubernetes/aio/client/models/v1_storage_class.py +++ b/kubernetes/aio/client/models/v1_storage_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_class_list.py b/kubernetes/aio/client/models/v1_storage_class_list.py index 4f7829d853..73b86f79e7 100644 --- a/kubernetes/aio/client/models/v1_storage_class_list.py +++ b/kubernetes/aio/client/models/v1_storage_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_health.py b/kubernetes/aio/client/models/v1_storage_health.py index 402e6bb8d2..5049a1365f 100644 --- a/kubernetes/aio/client/models/v1_storage_health.py +++ b/kubernetes/aio/client/models/v1_storage_health.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageHealth(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_health_condition.py b/kubernetes/aio/client/models/v1_storage_health_condition.py index bb1e294909..285e819e30 100644 --- a/kubernetes/aio/client/models/v1_storage_health_condition.py +++ b/kubernetes/aio/client/models/v1_storage_health_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageHealthCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_os_persistent_volume_source.py b/kubernetes/aio/client/models/v1_storage_os_persistent_volume_source.py index b238d82d40..f85014ce14 100644 --- a/kubernetes/aio/client/models/v1_storage_os_persistent_volume_source.py +++ b/kubernetes/aio/client/models/v1_storage_os_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageOSPersistentVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_os_volume_source.py b/kubernetes/aio/client/models/v1_storage_os_volume_source.py index ca84bbe50d..c95642282e 100644 --- a/kubernetes/aio/client/models/v1_storage_os_volume_source.py +++ b/kubernetes/aio/client/models/v1_storage_os_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageOSVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_version_migration.py b/kubernetes/aio/client/models/v1_storage_version_migration.py index 44493b7470..f6ff053ebc 100644 --- a/kubernetes/aio/client/models/v1_storage_version_migration.py +++ b/kubernetes/aio/client/models/v1_storage_version_migration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_version_migration_list.py b/kubernetes/aio/client/models/v1_storage_version_migration_list.py index 313548f920..150b7712a0 100644 --- a/kubernetes/aio/client/models/v1_storage_version_migration_list.py +++ b/kubernetes/aio/client/models/v1_storage_version_migration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_version_migration_spec.py b/kubernetes/aio/client/models/v1_storage_version_migration_spec.py index a06da83d5d..234e5ae844 100644 --- a/kubernetes/aio/client/models/v1_storage_version_migration_spec.py +++ b/kubernetes/aio/client/models/v1_storage_version_migration_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_storage_version_migration_status.py b/kubernetes/aio/client/models/v1_storage_version_migration_status.py index 82bcddfba6..4c7fc3a30c 100644 --- a/kubernetes/aio/client/models/v1_storage_version_migration_status.py +++ b/kubernetes/aio/client/models/v1_storage_version_migration_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_subject_access_review.py b/kubernetes/aio/client/models/v1_subject_access_review.py index 641e038b58..84cbbf2046 100644 --- a/kubernetes/aio/client/models/v1_subject_access_review.py +++ b/kubernetes/aio/client/models/v1_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_subject_access_review_spec.py b/kubernetes/aio/client/models/v1_subject_access_review_spec.py index 2a9c80be7f..8c044e18a2 100644 --- a/kubernetes/aio/client/models/v1_subject_access_review_spec.py +++ b/kubernetes/aio/client/models/v1_subject_access_review_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReviewSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_subject_access_review_status.py b/kubernetes/aio/client/models/v1_subject_access_review_status.py index 659acc35a8..b82eaad6d9 100644 --- a/kubernetes/aio/client/models/v1_subject_access_review_status.py +++ b/kubernetes/aio/client/models/v1_subject_access_review_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReviewStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_subject_rules_review_status.py b/kubernetes/aio/client/models/v1_subject_rules_review_status.py index f175010285..b253597f8b 100644 --- a/kubernetes/aio/client/models/v1_subject_rules_review_status.py +++ b/kubernetes/aio/client/models/v1_subject_rules_review_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectRulesReviewStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_success_policy.py b/kubernetes/aio/client/models/v1_success_policy.py index c4592b2d03..a150808fb0 100644 --- a/kubernetes/aio/client/models/v1_success_policy.py +++ b/kubernetes/aio/client/models/v1_success_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SuccessPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_success_policy_rule.py b/kubernetes/aio/client/models/v1_success_policy_rule.py index e6fc5f0879..5305415112 100644 --- a/kubernetes/aio/client/models/v1_success_policy_rule.py +++ b/kubernetes/aio/client/models/v1_success_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SuccessPolicyRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_sysctl.py b/kubernetes/aio/client/models/v1_sysctl.py index dabc77a8a4..4306ab6e67 100644 --- a/kubernetes/aio/client/models/v1_sysctl.py +++ b/kubernetes/aio/client/models/v1_sysctl.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Sysctl(BaseModel): diff --git a/kubernetes/aio/client/models/v1_taint.py b/kubernetes/aio/client/models/v1_taint.py index be641e0a12..7ad9e276a5 100644 --- a/kubernetes/aio/client/models/v1_taint.py +++ b/kubernetes/aio/client/models/v1_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Taint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_tcp_socket_action.py b/kubernetes/aio/client/models/v1_tcp_socket_action.py index 27fc2ef574..9bcfe4fc00 100644 --- a/kubernetes/aio/client/models/v1_tcp_socket_action.py +++ b/kubernetes/aio/client/models/v1_tcp_socket_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TCPSocketAction(BaseModel): diff --git a/kubernetes/aio/client/models/v1_token_request_spec.py b/kubernetes/aio/client/models/v1_token_request_spec.py index a96c435b75..5b420e3f22 100644 --- a/kubernetes/aio/client/models/v1_token_request_spec.py +++ b/kubernetes/aio/client/models/v1_token_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_token_request_status.py b/kubernetes/aio/client/models/v1_token_request_status.py index 5eb121fe1e..10f60ab86d 100644 --- a/kubernetes/aio/client/models/v1_token_request_status.py +++ b/kubernetes/aio/client/models/v1_token_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_token_review.py b/kubernetes/aio/client/models/v1_token_review.py index 5e37b45c41..d83118e5ae 100644 --- a/kubernetes/aio/client/models/v1_token_review.py +++ b/kubernetes/aio/client/models/v1_token_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReview(BaseModel): diff --git a/kubernetes/aio/client/models/v1_token_review_spec.py b/kubernetes/aio/client/models/v1_token_review_spec.py index 924084c43c..1e0fd94a88 100644 --- a/kubernetes/aio/client/models/v1_token_review_spec.py +++ b/kubernetes/aio/client/models/v1_token_review_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReviewSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_token_review_status.py b/kubernetes/aio/client/models/v1_token_review_status.py index a6361da9d3..c321c205a2 100644 --- a/kubernetes/aio/client/models/v1_token_review_status.py +++ b/kubernetes/aio/client/models/v1_token_review_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReviewStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_toleration.py b/kubernetes/aio/client/models/v1_toleration.py index 54710b50c1..2f644575f9 100644 --- a/kubernetes/aio/client/models/v1_toleration.py +++ b/kubernetes/aio/client/models/v1_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Toleration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_topology_selector_label_requirement.py b/kubernetes/aio/client/models/v1_topology_selector_label_requirement.py index d542bfcb3d..7cc754e666 100644 --- a/kubernetes/aio/client/models/v1_topology_selector_label_requirement.py +++ b/kubernetes/aio/client/models/v1_topology_selector_label_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySelectorLabelRequirement(BaseModel): diff --git a/kubernetes/aio/client/models/v1_topology_selector_term.py b/kubernetes/aio/client/models/v1_topology_selector_term.py index f3a6f3be59..a28afaa502 100644 --- a/kubernetes/aio/client/models/v1_topology_selector_term.py +++ b/kubernetes/aio/client/models/v1_topology_selector_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySelectorTerm(BaseModel): diff --git a/kubernetes/aio/client/models/v1_topology_spread_constraint.py b/kubernetes/aio/client/models/v1_topology_spread_constraint.py index e7f0c2630b..c2fd2f32d5 100644 --- a/kubernetes/aio/client/models/v1_topology_spread_constraint.py +++ b/kubernetes/aio/client/models/v1_topology_spread_constraint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySpreadConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1_type_checking.py b/kubernetes/aio/client/models/v1_type_checking.py index 31e49040bd..ef028419b5 100644 --- a/kubernetes/aio/client/models/v1_type_checking.py +++ b/kubernetes/aio/client/models/v1_type_checking.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypeChecking(BaseModel): diff --git a/kubernetes/aio/client/models/v1_typed_local_object_reference.py b/kubernetes/aio/client/models/v1_typed_local_object_reference.py index d921eaf0e0..b3a75c9e96 100644 --- a/kubernetes/aio/client/models/v1_typed_local_object_reference.py +++ b/kubernetes/aio/client/models/v1_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_typed_object_reference.py b/kubernetes/aio/client/models/v1_typed_object_reference.py index 83023a7754..73aadb48f9 100644 --- a/kubernetes/aio/client/models/v1_typed_object_reference.py +++ b/kubernetes/aio/client/models/v1_typed_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypedObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1_uncounted_terminated_pods.py b/kubernetes/aio/client/models/v1_uncounted_terminated_pods.py index 0cca4b4e58..ddfe891394 100644 --- a/kubernetes/aio/client/models/v1_uncounted_terminated_pods.py +++ b/kubernetes/aio/client/models/v1_uncounted_terminated_pods.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UncountedTerminatedPods(BaseModel): diff --git a/kubernetes/aio/client/models/v1_user_info.py b/kubernetes/aio/client/models/v1_user_info.py index 9c5f383db4..46fdbf426b 100644 --- a/kubernetes/aio/client/models/v1_user_info.py +++ b/kubernetes/aio/client/models/v1_user_info.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UserInfo(BaseModel): diff --git a/kubernetes/aio/client/models/v1_user_subject.py b/kubernetes/aio/client/models/v1_user_subject.py index 482e2f182c..3ce214b0e8 100644 --- a/kubernetes/aio/client/models/v1_user_subject.py +++ b/kubernetes/aio/client/models/v1_user_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UserSubject(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy.py b/kubernetes/aio/client/models/v1_validating_admission_policy.py index aa31dbf97c..5b10e69d86 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_binding.py b/kubernetes/aio/client/models/v1_validating_admission_policy_binding.py index af4e06fe85..684fb60f70 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_binding.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_binding_list.py b/kubernetes/aio/client/models/v1_validating_admission_policy_binding_list.py index 63fc768982..47cb4df818 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_binding_list.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_binding_spec.py b/kubernetes/aio/client/models/v1_validating_admission_policy_binding_spec.py index 08c61a3138..104320dc40 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_binding_spec.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_list.py b/kubernetes/aio/client/models/v1_validating_admission_policy_list.py index 0ddcf12c9b..ad8bc115ef 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_list.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_spec.py b/kubernetes/aio/client/models/v1_validating_admission_policy_spec.py index 5828b1efa3..21395542e3 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_spec.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_spec.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_admission_policy_status.py b/kubernetes/aio/client/models/v1_validating_admission_policy_status.py index b98e57c0d7..53f053b45f 100644 --- a/kubernetes/aio/client/models/v1_validating_admission_policy_status.py +++ b/kubernetes/aio/client/models/v1_validating_admission_policy_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_webhook.py b/kubernetes/aio/client/models/v1_validating_webhook.py index e0e68819d3..167adeb62a 100644 --- a/kubernetes/aio/client/models/v1_validating_webhook.py +++ b/kubernetes/aio/client/models/v1_validating_webhook.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhook(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_webhook_configuration.py b/kubernetes/aio/client/models/v1_validating_webhook_configuration.py index 828251eb15..a3f7fb66e1 100644 --- a/kubernetes/aio/client/models/v1_validating_webhook_configuration.py +++ b/kubernetes/aio/client/models/v1_validating_webhook_configuration.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhookConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validating_webhook_configuration_list.py b/kubernetes/aio/client/models/v1_validating_webhook_configuration_list.py index 19155725c2..482b8e89c5 100644 --- a/kubernetes/aio/client/models/v1_validating_webhook_configuration_list.py +++ b/kubernetes/aio/client/models/v1_validating_webhook_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhookConfigurationList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validation.py b/kubernetes/aio/client/models/v1_validation.py index fe1261dcde..eab82c70c6 100644 --- a/kubernetes/aio/client/models/v1_validation.py +++ b/kubernetes/aio/client/models/v1_validation.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Validation(BaseModel): diff --git a/kubernetes/aio/client/models/v1_validation_rule.py b/kubernetes/aio/client/models/v1_validation_rule.py index 8b8ada19ce..f9ee8dd64e 100644 --- a/kubernetes/aio/client/models/v1_validation_rule.py +++ b/kubernetes/aio/client/models/v1_validation_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidationRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1_variable.py b/kubernetes/aio/client/models/v1_variable.py index 85afec93de..809cec1012 100644 --- a/kubernetes/aio/client/models/v1_variable.py +++ b/kubernetes/aio/client/models/v1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Variable(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume.py b/kubernetes/aio/client/models/v1_volume.py index 4193f8c57a..d497e890e8 100644 --- a/kubernetes/aio/client/models/v1_volume.py +++ b/kubernetes/aio/client/models/v1_volume.py @@ -55,72 +55,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Volume(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attachment.py b/kubernetes/aio/client/models/v1_volume_attachment.py index 793348217e..59a7da04b2 100644 --- a/kubernetes/aio/client/models/v1_volume_attachment.py +++ b/kubernetes/aio/client/models/v1_volume_attachment.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachment(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attachment_list.py b/kubernetes/aio/client/models/v1_volume_attachment_list.py index cd46526e2d..a9c297d8c6 100644 --- a/kubernetes/aio/client/models/v1_volume_attachment_list.py +++ b/kubernetes/aio/client/models/v1_volume_attachment_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attachment_source.py b/kubernetes/aio/client/models/v1_volume_attachment_source.py index b3d3bdc31c..9ab3efc752 100644 --- a/kubernetes/aio/client/models/v1_volume_attachment_source.py +++ b/kubernetes/aio/client/models/v1_volume_attachment_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attachment_spec.py b/kubernetes/aio/client/models/v1_volume_attachment_spec.py index ade99952e0..5d23072398 100644 --- a/kubernetes/aio/client/models/v1_volume_attachment_spec.py +++ b/kubernetes/aio/client/models/v1_volume_attachment_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attachment_status.py b/kubernetes/aio/client/models/v1_volume_attachment_status.py index 8b3f4d2767..ecaa5905d8 100644 --- a/kubernetes/aio/client/models/v1_volume_attachment_status.py +++ b/kubernetes/aio/client/models/v1_volume_attachment_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attributes_class.py b/kubernetes/aio/client/models/v1_volume_attributes_class.py index 70c576e2e8..99315fd35f 100644 --- a/kubernetes/aio/client/models/v1_volume_attributes_class.py +++ b/kubernetes/aio/client/models/v1_volume_attributes_class.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttributesClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_attributes_class_list.py b/kubernetes/aio/client/models/v1_volume_attributes_class_list.py index bbe99d8a8d..77e3e1286c 100644 --- a/kubernetes/aio/client/models/v1_volume_attributes_class_list.py +++ b/kubernetes/aio/client/models/v1_volume_attributes_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttributesClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_device.py b/kubernetes/aio/client/models/v1_volume_device.py index 2b27569ddc..b19354cd65 100644 --- a/kubernetes/aio/client/models/v1_volume_device.py +++ b/kubernetes/aio/client/models/v1_volume_device.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeDevice(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_error.py b/kubernetes/aio/client/models/v1_volume_error.py index b56518a667..bb9df51443 100644 --- a/kubernetes/aio/client/models/v1_volume_error.py +++ b/kubernetes/aio/client/models/v1_volume_error.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeError(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_health_condition.py b/kubernetes/aio/client/models/v1_volume_health_condition.py index b92cc17235..583e433681 100644 --- a/kubernetes/aio/client/models/v1_volume_health_condition.py +++ b/kubernetes/aio/client/models/v1_volume_health_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeHealthCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_health_status.py b/kubernetes/aio/client/models/v1_volume_health_status.py index 8870315e66..ebe8bdcbd7 100644 --- a/kubernetes/aio/client/models/v1_volume_health_status.py +++ b/kubernetes/aio/client/models/v1_volume_health_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeHealthStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_mount.py b/kubernetes/aio/client/models/v1_volume_mount.py index 630f75986c..b5b9c7ec60 100644 --- a/kubernetes/aio/client/models/v1_volume_mount.py +++ b/kubernetes/aio/client/models/v1_volume_mount.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeMount(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_mount_status.py b/kubernetes/aio/client/models/v1_volume_mount_status.py index 272b75be9a..65504f2ece 100644 --- a/kubernetes/aio/client/models/v1_volume_mount_status.py +++ b/kubernetes/aio/client/models/v1_volume_mount_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeMountStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_node_affinity.py b/kubernetes/aio/client/models/v1_volume_node_affinity.py index 22385b793c..ab1f4e1a1e 100644 --- a/kubernetes/aio/client/models/v1_volume_node_affinity.py +++ b/kubernetes/aio/client/models/v1_volume_node_affinity.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeNodeAffinity(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_node_resources.py b/kubernetes/aio/client/models/v1_volume_node_resources.py index 02188efbe8..1a905ae608 100644 --- a/kubernetes/aio/client/models/v1_volume_node_resources.py +++ b/kubernetes/aio/client/models/v1_volume_node_resources.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeNodeResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_projection.py b/kubernetes/aio/client/models/v1_volume_projection.py index d5b129d24a..cbdb645583 100644 --- a/kubernetes/aio/client/models/v1_volume_projection.py +++ b/kubernetes/aio/client/models/v1_volume_projection.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeProjection(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_resource_requirements.py b/kubernetes/aio/client/models/v1_volume_resource_requirements.py index 6c04018d83..51462dec50 100644 --- a/kubernetes/aio/client/models/v1_volume_resource_requirements.py +++ b/kubernetes/aio/client/models/v1_volume_resource_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeResourceRequirements(BaseModel): diff --git a/kubernetes/aio/client/models/v1_volume_status.py b/kubernetes/aio/client/models/v1_volume_status.py index 0c3fa145bc..d2ab514599 100644 --- a/kubernetes/aio/client/models/v1_volume_status.py +++ b/kubernetes/aio/client/models/v1_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1_vsphere_virtual_disk_volume_source.py b/kubernetes/aio/client/models/v1_vsphere_virtual_disk_volume_source.py index 19d2ea360c..e8846509a2 100644 --- a/kubernetes/aio/client/models/v1_vsphere_virtual_disk_volume_source.py +++ b/kubernetes/aio/client/models/v1_vsphere_virtual_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VsphereVirtualDiskVolumeSource(BaseModel): diff --git a/kubernetes/aio/client/models/v1_watch_event.py b/kubernetes/aio/client/models/v1_watch_event.py index 6b14f770c4..2f1066d795 100644 --- a/kubernetes/aio/client/models/v1_watch_event.py +++ b/kubernetes/aio/client/models/v1_watch_event.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WatchEvent(BaseModel): diff --git a/kubernetes/aio/client/models/v1_webhook_conversion.py b/kubernetes/aio/client/models/v1_webhook_conversion.py index 65e0f30073..eb9a21ddcb 100644 --- a/kubernetes/aio/client/models/v1_webhook_conversion.py +++ b/kubernetes/aio/client/models/v1_webhook_conversion.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WebhookConversion(BaseModel): diff --git a/kubernetes/aio/client/models/v1_weighted_pod_affinity_term.py b/kubernetes/aio/client/models/v1_weighted_pod_affinity_term.py index 0450f11976..5587d0c796 100644 --- a/kubernetes/aio/client/models/v1_weighted_pod_affinity_term.py +++ b/kubernetes/aio/client/models/v1_weighted_pod_affinity_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WeightedPodAffinityTerm(BaseModel): diff --git a/kubernetes/aio/client/models/v1_windows_security_context_options.py b/kubernetes/aio/client/models/v1_windows_security_context_options.py index 1ec877ca90..3b9ff82f52 100644 --- a/kubernetes/aio/client/models/v1_windows_security_context_options.py +++ b/kubernetes/aio/client/models/v1_windows_security_context_options.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WindowsSecurityContextOptions(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_apply_configuration.py b/kubernetes/aio/client/models/v1alpha1_apply_configuration.py index 9e1e35dfd3..624a4e87f9 100644 --- a/kubernetes/aio/client/models/v1alpha1_apply_configuration.py +++ b/kubernetes/aio/client/models/v1alpha1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ApplyConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction.py b/kubernetes/aio/client/models/v1alpha1_eviction.py index 76b928af65..7133739949 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Eviction(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_list.py b/kubernetes/aio/client/models/v1alpha1_eviction_list.py index 753b26b0c9..a75578bc5a 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_list.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_pod_reference.py b/kubernetes/aio/client/models/v1alpha1_eviction_pod_reference.py index 5968fe2b9d..1a0aedceda 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_pod_reference.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_pod_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionPodReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request.py b/kubernetes/aio/client/models/v1alpha1_eviction_request.py index 2c4b77dc91..76f86e45a5 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request_list.py b/kubernetes/aio/client/models/v1alpha1_eviction_request_list.py index fd872b74c9..0316542f58 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request_list.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request_pod_reference.py b/kubernetes/aio/client/models/v1alpha1_eviction_request_pod_reference.py index 572360589c..ea78566bb5 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request_pod_reference.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request_pod_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestPodReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request_spec.py b/kubernetes/aio/client/models/v1alpha1_eviction_request_spec.py index a71fd55a9a..d254a1a48d 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request_spec.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request_status.py b/kubernetes/aio/client/models/v1alpha1_eviction_request_status.py index 4a331fab2c..fe6ea62ae1 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request_status.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_request_target.py b/kubernetes/aio/client/models/v1alpha1_eviction_request_target.py index 7d2296c2be..a0c7945920 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_request_target.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_request_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestTarget(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_spec.py b/kubernetes/aio/client/models/v1alpha1_eviction_spec.py index 46a21cdb15..1e64b1b31e 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_spec.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_status.py b/kubernetes/aio/client/models/v1alpha1_eviction_status.py index 299ec766e8..aaadb8aafb 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_status.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_status.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_eviction_target.py b/kubernetes/aio/client/models/v1alpha1_eviction_target.py index ae60e759ac..1ed5263b0b 100644 --- a/kubernetes/aio/client/models/v1alpha1_eviction_target.py +++ b/kubernetes/aio/client/models/v1alpha1_eviction_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionTarget(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_json_patch.py b/kubernetes/aio/client/models/v1alpha1_json_patch.py index 5a3b3d5a18..db01891c11 100644 --- a/kubernetes/aio/client/models/v1alpha1_json_patch.py +++ b/kubernetes/aio/client/models/v1alpha1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1JSONPatch(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_match_condition.py b/kubernetes/aio/client/models/v1alpha1_match_condition.py index c655fdf308..412899a50e 100644 --- a/kubernetes/aio/client/models/v1alpha1_match_condition.py +++ b/kubernetes/aio/client/models/v1alpha1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MatchCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_match_resources.py b/kubernetes/aio/client/models/v1alpha1_match_resources.py index c60bdd47b4..90bb6b37d9 100644 --- a/kubernetes/aio/client/models/v1alpha1_match_resources.py +++ b/kubernetes/aio/client/models/v1alpha1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MatchResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy.py index 4dd68e2bea..af6eb4612e 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding.py index 5be4cac3e5..9621b2f21e 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_list.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_list.py index 5390d316d7..42330d322e 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_list.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_spec.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_spec.py index 5da6e8b5ef..624a2cf462 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_list.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_list.py index 6bcea94f0c..af18e5e4a5 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_list.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_spec.py b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_spec.py index a226a3ede9..5d4fda5d9c 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_spec.py +++ b/kubernetes/aio/client/models/v1alpha1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_mutation.py b/kubernetes/aio/client/models/v1alpha1_mutation.py index 119315bf70..479a46bccb 100644 --- a/kubernetes/aio/client/models/v1alpha1_mutation.py +++ b/kubernetes/aio/client/models/v1alpha1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Mutation(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_named_rule_with_operations.py b/kubernetes/aio/client/models/v1alpha1_named_rule_with_operations.py index fb89670257..2c662e640f 100644 --- a/kubernetes/aio/client/models/v1alpha1_named_rule_with_operations.py +++ b/kubernetes/aio/client/models/v1alpha1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_param_kind.py b/kubernetes/aio/client/models/v1alpha1_param_kind.py index 7f0462813c..cb0d98497b 100644 --- a/kubernetes/aio/client/models/v1alpha1_param_kind.py +++ b/kubernetes/aio/client/models/v1alpha1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ParamKind(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_param_ref.py b/kubernetes/aio/client/models/v1alpha1_param_ref.py index 515110cb71..27c8a7070b 100644 --- a/kubernetes/aio/client/models/v1alpha1_param_ref.py +++ b/kubernetes/aio/client/models/v1alpha1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ParamRef(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_requester.py b/kubernetes/aio/client/models/v1alpha1_requester.py index d0f68ab078..604601563d 100644 --- a/kubernetes/aio/client/models/v1alpha1_requester.py +++ b/kubernetes/aio/client/models/v1alpha1_requester.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Requester(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_responder_status.py b/kubernetes/aio/client/models/v1alpha1_responder_status.py index 7ba7b7ed55..8d33fc8d16 100644 --- a/kubernetes/aio/client/models/v1alpha1_responder_status.py +++ b/kubernetes/aio/client/models/v1alpha1_responder_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ResponderStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_server_storage_version.py b/kubernetes/aio/client/models/v1alpha1_server_storage_version.py index 903fc9ddc6..5e6d42fbc5 100644 --- a/kubernetes/aio/client/models/v1alpha1_server_storage_version.py +++ b/kubernetes/aio/client/models/v1alpha1_server_storage_version.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ServerStorageVersion(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_storage_version.py b/kubernetes/aio/client/models/v1alpha1_storage_version.py index 3a6165fffa..b4172841a0 100644 --- a/kubernetes/aio/client/models/v1alpha1_storage_version.py +++ b/kubernetes/aio/client/models/v1alpha1_storage_version.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersion(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_storage_version_condition.py b/kubernetes/aio/client/models/v1alpha1_storage_version_condition.py index f2d0575fba..b6c8b73713 100644 --- a/kubernetes/aio/client/models/v1alpha1_storage_version_condition.py +++ b/kubernetes/aio/client/models/v1alpha1_storage_version_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_storage_version_list.py b/kubernetes/aio/client/models/v1alpha1_storage_version_list.py index d31e8d01f2..266bf29f95 100644 --- a/kubernetes/aio/client/models/v1alpha1_storage_version_list.py +++ b/kubernetes/aio/client/models/v1alpha1_storage_version_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_storage_version_status.py b/kubernetes/aio/client/models/v1alpha1_storage_version_status.py index 139587cbb2..6fc7eb7986 100644 --- a/kubernetes/aio/client/models/v1alpha1_storage_version_status.py +++ b/kubernetes/aio/client/models/v1alpha1_storage_version_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_target_responder.py b/kubernetes/aio/client/models/v1alpha1_target_responder.py index 60a2562a80..c618513406 100644 --- a/kubernetes/aio/client/models/v1alpha1_target_responder.py +++ b/kubernetes/aio/client/models/v1alpha1_target_responder.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1TargetResponder(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha1_variable.py b/kubernetes/aio/client/models/v1alpha1_variable.py index eb7fbcce4b..a3ebf1bd5f 100644 --- a/kubernetes/aio/client/models/v1alpha1_variable.py +++ b/kubernetes/aio/client/models/v1alpha1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Variable(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha2_lease_candidate.py b/kubernetes/aio/client/models/v1alpha2_lease_candidate.py index c9e9e93e09..0df77cff78 100644 --- a/kubernetes/aio/client/models/v1alpha2_lease_candidate.py +++ b/kubernetes/aio/client/models/v1alpha2_lease_candidate.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidate(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha2_lease_candidate_list.py b/kubernetes/aio/client/models/v1alpha2_lease_candidate_list.py index 1c65e848d3..aacd1757fe 100644 --- a/kubernetes/aio/client/models/v1alpha2_lease_candidate_list.py +++ b/kubernetes/aio/client/models/v1alpha2_lease_candidate_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha2_lease_candidate_spec.py b/kubernetes/aio/client/models/v1alpha2_lease_candidate_spec.py index 921b5b6ac7..04a26a5fa0 100644 --- a/kubernetes/aio/client/models/v1alpha2_lease_candidate_spec.py +++ b/kubernetes/aio/client/models/v1alpha2_lease_candidate_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_disruption_mode.py b/kubernetes/aio/client/models/v1alpha3_composite_disruption_mode.py index 395543ca17..8303fefd31 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_disruption_mode.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositeDisruptionMode(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_gang_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_composite_gang_scheduling_policy.py index b19cc716bf..41c7c20046 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_gang_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositeGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group.py index 4e8e3f0197..f146cfcd91 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroup(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_list.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_list.py index 16243037b5..3cb10ceac1 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_list.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py index bebaa3216c..844d2c0ad9 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_policy.py index 1d45d912c1..f42be46f9e 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_spec.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_spec.py index 053ce5539f..9c29a2ff4e 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_spec.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_status.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_status.py index 11acdfee01..36c2213374 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_status.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_template.py b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_template.py index a6bd811edc..652e273a4b 100644 --- a/kubernetes/aio/client/models/v1alpha3_composite_pod_group_template.py +++ b/kubernetes/aio/client/models/v1alpha3_composite_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint.py b/kubernetes/aio/client/models/v1alpha3_device_taint.py index 89a152458d..af7ffe15b6 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaint(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint_rule.py b/kubernetes/aio/client/models/v1alpha3_device_taint_rule.py index 6b53211bdf..fc50e7709e 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint_rule.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_list.py b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_list.py index 2c1e9623b4..d95466f90a 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_list.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_spec.py b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_spec.py index b838b31d4b..dc286a323d 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_spec.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_status.py b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_status.py index 7149017f7c..a7dbb08afa 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint_rule_status.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_device_taint_selector.py b/kubernetes/aio/client/models/v1alpha3_device_taint_selector.py index 78bcc9a8fa..9d15b18d9d 100644 --- a/kubernetes/aio/client/models/v1alpha3_device_taint_selector.py +++ b/kubernetes/aio/client/models/v1alpha3_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_disruption_mode.py b/kubernetes/aio/client/models/v1alpha3_disruption_mode.py index f72f9664af..b73c91193c 100644 --- a/kubernetes/aio/client/models/v1alpha3_disruption_mode.py +++ b/kubernetes/aio/client/models/v1alpha3_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DisruptionMode(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_gang_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_gang_scheduling_policy.py index 120249017d..87ba26b3fe 100644 --- a/kubernetes/aio/client/models/v1alpha3_gang_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3GangSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_partition_type_status.py b/kubernetes/aio/client/models/v1alpha3_partition_type_status.py index 7c9dbd1aa8..733027263a 100644 --- a/kubernetes/aio/client/models/v1alpha3_partition_type_status.py +++ b/kubernetes/aio/client/models/v1alpha3_partition_type_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PartitionTypeStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group.py b/kubernetes/aio/client/models/v1alpha3_pod_group.py index 17d8d6ddea..5bfccccf38 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroup(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_list.py b/kubernetes/aio/client/models/v1alpha3_pod_group_list.py index f4e6e5d834..23de1223e3 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_list.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim.py b/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim.py index cbce33ffab..2785afff5d 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim_status.py b/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim_status.py index 0efbbdc597..f5189387b4 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_constraints.py b/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_constraints.py index 86c1ec1cb5..146e5ab990 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_constraints.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_policy.py index 8612d4ffe5..3f2f6e4dca 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_spec.py b/kubernetes/aio/client/models/v1alpha3_pod_group_spec.py index 7884254d21..e03aa7519a 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_spec.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_status.py b/kubernetes/aio/client/models/v1alpha3_pod_group_status.py index 1cb6236bc7..9dcf7f26c8 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_status.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pod_group_template.py b/kubernetes/aio/client/models/v1alpha3_pod_group_template.py index af316d9b23..44ba68ddc0 100644 --- a/kubernetes/aio/client/models/v1alpha3_pod_group_template.py +++ b/kubernetes/aio/client/models/v1alpha3_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_pool_status.py b/kubernetes/aio/client/models/v1alpha3_pool_status.py index f302529aea..7e287ae5c7 100644 --- a/kubernetes/aio/client/models/v1alpha3_pool_status.py +++ b/kubernetes/aio/client/models/v1alpha3_pool_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PoolStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request.py b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request.py index 5236c6ad00..91942861cc 100644 --- a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request.py +++ b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_list.py b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_list.py index 074a3de862..7b9f4007df 100644 --- a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_list.py +++ b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_spec.py b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_spec.py index a8a5e1e6a3..a081642a12 100644 --- a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_spec.py +++ b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_status.py b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_status.py index 924c6787f3..1f3c080071 100644 --- a/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_status.py +++ b/kubernetes/aio/client/models/v1alpha3_resource_pool_status_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_shareable_capacity_status.py b/kubernetes/aio/client/models/v1alpha3_shareable_capacity_status.py index eca187aa22..631ea0bc31 100644 --- a/kubernetes/aio/client/models/v1alpha3_shareable_capacity_status.py +++ b/kubernetes/aio/client/models/v1alpha3_shareable_capacity_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ShareableCapacityStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_shareable_summary_status.py b/kubernetes/aio/client/models/v1alpha3_shareable_summary_status.py index 362c5c7202..ac9f3dbb42 100644 --- a/kubernetes/aio/client/models/v1alpha3_shareable_summary_status.py +++ b/kubernetes/aio/client/models/v1alpha3_shareable_summary_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ShareableSummaryStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_topology_constraint.py b/kubernetes/aio/client/models/v1alpha3_topology_constraint.py index a4aa134adb..017b13a1df 100644 --- a/kubernetes/aio/client/models/v1alpha3_topology_constraint.py +++ b/kubernetes/aio/client/models/v1alpha3_topology_constraint.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3TopologyConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_typed_local_object_reference.py b/kubernetes/aio/client/models/v1alpha3_typed_local_object_reference.py index 35138b5a4b..2450c718ae 100644 --- a/kubernetes/aio/client/models/v1alpha3_typed_local_object_reference.py +++ b/kubernetes/aio/client/models/v1alpha3_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload.py b/kubernetes/aio/client/models/v1alpha3_workload.py index d941f090b7..3db66948d4 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload.py +++ b/kubernetes/aio/client/models/v1alpha3_workload.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3Workload(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_list.py b/kubernetes/aio/client/models/v1alpha3_workload_list.py index 82ec70dd6b..1aef0b0938 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_list.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadList(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_disruption_mode.py b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_disruption_mode.py index 557d4b84f9..2dceb910f8 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_disruption_mode.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupDisruptionMode(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py index 9c29d59e3c..86b47001ee 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_resource_claim.py b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_resource_claim.py index b983a4c561..df69dc57fc 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_resource_claim.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py index 66da9c17da..0f7e301937 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_policy.py b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_policy.py index 6aa96b4c57..3054aa9936 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_reference.py b/kubernetes/aio/client/models/v1alpha3_workload_reference.py index eb786d9462..68612c4d89 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_reference.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1alpha3_workload_spec.py b/kubernetes/aio/client/models/v1alpha3_workload_spec.py index e17b7d8ff6..73b556a90f 100644 --- a/kubernetes/aio/client/models/v1alpha3_workload_spec.py +++ b/kubernetes/aio/client/models/v1alpha3_workload_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_allocated_device_status.py b/kubernetes/aio/client/models/v1beta1_allocated_device_status.py index 89458b516a..3ff8bfc7fc 100644 --- a/kubernetes/aio/client/models/v1beta1_allocated_device_status.py +++ b/kubernetes/aio/client/models/v1beta1_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_allocation_result.py b/kubernetes/aio/client/models/v1beta1_allocation_result.py index ced2df8da0..7e1939562e 100644 --- a/kubernetes/aio/client/models/v1beta1_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta1_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1AllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_apply_configuration.py b/kubernetes/aio/client/models/v1beta1_apply_configuration.py index 21dd6e1cc9..d521b18247 100644 --- a/kubernetes/aio/client/models/v1beta1_apply_configuration.py +++ b/kubernetes/aio/client/models/v1beta1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ApplyConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_basic_device.py b/kubernetes/aio/client/models/v1beta1_basic_device.py index c50369b61c..fc6c8a6024 100644 --- a/kubernetes/aio/client/models/v1beta1_basic_device.py +++ b/kubernetes/aio/client/models/v1beta1_basic_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1BasicDevice(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_capacity_request_policy.py b/kubernetes/aio/client/models/v1beta1_capacity_request_policy.py index 20c3342146..12d2b217e9 100644 --- a/kubernetes/aio/client/models/v1beta1_capacity_request_policy.py +++ b/kubernetes/aio/client/models/v1beta1_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_capacity_request_policy_range.py b/kubernetes/aio/client/models/v1beta1_capacity_request_policy_range.py index e85a6838e2..cec67b9505 100644 --- a/kubernetes/aio/client/models/v1beta1_capacity_request_policy_range.py +++ b/kubernetes/aio/client/models/v1beta1_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_capacity_requirements.py b/kubernetes/aio/client/models/v1beta1_capacity_requirements.py index 20f33aad50..d9d68eaa37 100644 --- a/kubernetes/aio/client/models/v1beta1_capacity_requirements.py +++ b/kubernetes/aio/client/models/v1beta1_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequirements(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_cel_device_selector.py b/kubernetes/aio/client/models/v1beta1_cel_device_selector.py index 7ef8bb1815..cffacc7772 100644 --- a/kubernetes/aio/client/models/v1beta1_cel_device_selector.py +++ b/kubernetes/aio/client/models/v1beta1_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CELDeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle.py b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle.py index 13a9ebe7f8..d094c5c3dc 100644 --- a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle.py +++ b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundle(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_list.py b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_list.py index 2d95ab441b..9d3e103cf6 100644 --- a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_list.py +++ b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_spec.py b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_spec.py index c35343969f..f0076de959 100644 --- a/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_spec.py +++ b/kubernetes/aio/client/models/v1beta1_cluster_trust_bundle_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_composite_disruption_mode.py b/kubernetes/aio/client/models/v1beta1_composite_disruption_mode.py index 8b60442961..41219a6761 100644 --- a/kubernetes/aio/client/models/v1beta1_composite_disruption_mode.py +++ b/kubernetes/aio/client/models/v1beta1_composite_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositeDisruptionMode(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_composite_gang_scheduling_policy.py b/kubernetes/aio/client/models/v1beta1_composite_gang_scheduling_policy.py index e283a3554d..f12c8d4de8 100644 --- a/kubernetes/aio/client/models/v1beta1_composite_gang_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1beta1_composite_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositeGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_constraints.py b/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_constraints.py index 07b923b673..5a7f20696b 100644 --- a/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_constraints.py +++ b/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_policy.py b/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_policy.py index 245056b863..349e3e4541 100644 --- a/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1beta1_composite_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_composite_pod_group_template.py b/kubernetes/aio/client/models/v1beta1_composite_pod_group_template.py index f1005ea30b..9e4550ccdd 100644 --- a/kubernetes/aio/client/models/v1beta1_composite_pod_group_template.py +++ b/kubernetes/aio/client/models/v1beta1_composite_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_counter.py b/kubernetes/aio/client/models/v1beta1_counter.py index 8c84101fbb..423a5f8be1 100644 --- a/kubernetes/aio/client/models/v1beta1_counter.py +++ b/kubernetes/aio/client/models/v1beta1_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Counter(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_counter_set.py b/kubernetes/aio/client/models/v1beta1_counter_set.py index b88247cc15..bd7b8eff27 100644 --- a/kubernetes/aio/client/models/v1beta1_counter_set.py +++ b/kubernetes/aio/client/models/v1beta1_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CounterSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device.py b/kubernetes/aio/client/models/v1beta1_device.py index 41e70358dd..e570b6f9d0 100644 --- a/kubernetes/aio/client/models/v1beta1_device.py +++ b/kubernetes/aio/client/models/v1beta1_device.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Device(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_allocation_configuration.py b/kubernetes/aio/client/models/v1beta1_device_allocation_configuration.py index 05889d9642..04f25e75eb 100644 --- a/kubernetes/aio/client/models/v1beta1_device_allocation_configuration.py +++ b/kubernetes/aio/client/models/v1beta1_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_allocation_result.py b/kubernetes/aio/client/models/v1beta1_device_allocation_result.py index 6f20079318..c808a2dd6e 100644 --- a/kubernetes/aio/client/models/v1beta1_device_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta1_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_attribute.py b/kubernetes/aio/client/models/v1beta1_device_attribute.py index 1bdd422644..be3ac46c0a 100644 --- a/kubernetes/aio/client/models/v1beta1_device_attribute.py +++ b/kubernetes/aio/client/models/v1beta1_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_capacity.py b/kubernetes/aio/client/models/v1beta1_device_capacity.py index 7ea03de896..85ca558f88 100644 --- a/kubernetes/aio/client/models/v1beta1_device_capacity.py +++ b/kubernetes/aio/client/models/v1beta1_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceCapacity(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_claim.py b/kubernetes/aio/client/models/v1beta1_device_claim.py index e44bfc0a0a..cedd1b9e4e 100644 --- a/kubernetes/aio/client/models/v1beta1_device_claim.py +++ b/kubernetes/aio/client/models/v1beta1_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_claim_configuration.py b/kubernetes/aio/client/models/v1beta1_device_claim_configuration.py index 97a697a8fb..1fe2c99ee8 100644 --- a/kubernetes/aio/client/models/v1beta1_device_claim_configuration.py +++ b/kubernetes/aio/client/models/v1beta1_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_class.py b/kubernetes/aio/client/models/v1beta1_device_class.py index 3e4a8fcf75..6c307cf122 100644 --- a/kubernetes/aio/client/models/v1beta1_device_class.py +++ b/kubernetes/aio/client/models/v1beta1_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_class_configuration.py b/kubernetes/aio/client/models/v1beta1_device_class_configuration.py index 01b72409df..3c6efa7cc4 100644 --- a/kubernetes/aio/client/models/v1beta1_device_class_configuration.py +++ b/kubernetes/aio/client/models/v1beta1_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_class_list.py b/kubernetes/aio/client/models/v1beta1_device_class_list.py index b3a840290b..4472934700 100644 --- a/kubernetes/aio/client/models/v1beta1_device_class_list.py +++ b/kubernetes/aio/client/models/v1beta1_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_class_spec.py b/kubernetes/aio/client/models/v1beta1_device_class_spec.py index 828b3b7866..6cb6193e7b 100644 --- a/kubernetes/aio/client/models/v1beta1_device_class_spec.py +++ b/kubernetes/aio/client/models/v1beta1_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_constraint.py b/kubernetes/aio/client/models/v1beta1_device_constraint.py index c5a0ca77e5..5869a9ab96 100644 --- a/kubernetes/aio/client/models/v1beta1_device_constraint.py +++ b/kubernetes/aio/client/models/v1beta1_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_counter_consumption.py b/kubernetes/aio/client/models/v1beta1_device_counter_consumption.py index 022ae7315a..10f15a967b 100644 --- a/kubernetes/aio/client/models/v1beta1_device_counter_consumption.py +++ b/kubernetes/aio/client/models/v1beta1_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_derived_attribute.py b/kubernetes/aio/client/models/v1beta1_device_derived_attribute.py index dc624e45ce..04be63e09b 100644 --- a/kubernetes/aio/client/models/v1beta1_device_derived_attribute.py +++ b/kubernetes/aio/client/models/v1beta1_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_request.py b/kubernetes/aio/client/models/v1beta1_device_request.py index c6f712206d..a1437c7e7b 100644 --- a/kubernetes/aio/client/models/v1beta1_device_request.py +++ b/kubernetes/aio/client/models/v1beta1_device_request.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_request_allocation_result.py b/kubernetes/aio/client/models/v1beta1_device_request_allocation_result.py index 4498376f22..dc42057ed0 100644 --- a/kubernetes/aio/client/models/v1beta1_device_request_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta1_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_selector.py b/kubernetes/aio/client/models/v1beta1_device_selector.py index ab170e3f84..79739cc023 100644 --- a/kubernetes/aio/client/models/v1beta1_device_selector.py +++ b/kubernetes/aio/client/models/v1beta1_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_sub_request.py b/kubernetes/aio/client/models/v1beta1_device_sub_request.py index 9e5f33a667..0a22952bbe 100644 --- a/kubernetes/aio/client/models/v1beta1_device_sub_request.py +++ b/kubernetes/aio/client/models/v1beta1_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceSubRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_taint.py b/kubernetes/aio/client/models/v1beta1_device_taint.py index 6fdc0e16ec..b22ba112c9 100644 --- a/kubernetes/aio/client/models/v1beta1_device_taint.py +++ b/kubernetes/aio/client/models/v1beta1_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceTaint(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_device_toleration.py b/kubernetes/aio/client/models/v1beta1_device_toleration.py index 1e7c1a5003..92b6f1bd62 100644 --- a/kubernetes/aio/client/models/v1beta1_device_toleration.py +++ b/kubernetes/aio/client/models/v1beta1_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceToleration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_disruption_mode.py b/kubernetes/aio/client/models/v1beta1_disruption_mode.py index a396c7971a..a98eb69227 100644 --- a/kubernetes/aio/client/models/v1beta1_disruption_mode.py +++ b/kubernetes/aio/client/models/v1beta1_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DisruptionMode(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_gang_scheduling_policy.py b/kubernetes/aio/client/models/v1beta1_gang_scheduling_policy.py index bdb153abe0..e2912aaf77 100644 --- a/kubernetes/aio/client/models/v1beta1_gang_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1beta1_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1GangSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_json_patch.py b/kubernetes/aio/client/models/v1beta1_json_patch.py index bf23cd7e21..799b4a4485 100644 --- a/kubernetes/aio/client/models/v1beta1_json_patch.py +++ b/kubernetes/aio/client/models/v1beta1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1JSONPatch(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_lease_candidate.py b/kubernetes/aio/client/models/v1beta1_lease_candidate.py index d305bbd22e..d44665133a 100644 --- a/kubernetes/aio/client/models/v1beta1_lease_candidate.py +++ b/kubernetes/aio/client/models/v1beta1_lease_candidate.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidate(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_lease_candidate_list.py b/kubernetes/aio/client/models/v1beta1_lease_candidate_list.py index 54e38652a4..9296d81974 100644 --- a/kubernetes/aio/client/models/v1beta1_lease_candidate_list.py +++ b/kubernetes/aio/client/models/v1beta1_lease_candidate_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_lease_candidate_spec.py b/kubernetes/aio/client/models/v1beta1_lease_candidate_spec.py index deff7e1e97..4dd735b07d 100644 --- a/kubernetes/aio/client/models/v1beta1_lease_candidate_spec.py +++ b/kubernetes/aio/client/models/v1beta1_lease_candidate_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_match_condition.py b/kubernetes/aio/client/models/v1beta1_match_condition.py index 41a83a76e0..84ee75c000 100644 --- a/kubernetes/aio/client/models/v1beta1_match_condition.py +++ b/kubernetes/aio/client/models/v1beta1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MatchCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_match_resources.py b/kubernetes/aio/client/models/v1beta1_match_resources.py index ba2c314362..a849a279d9 100644 --- a/kubernetes/aio/client/models/v1beta1_match_resources.py +++ b/kubernetes/aio/client/models/v1beta1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MatchResources(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy.py index 27b6b88358..3072a66854 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding.py index 5f6768c6d3..3a8fc24c0c 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_list.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_list.py index 2a406f18ee..b5fe6ee40e 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_list.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_spec.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_spec.py index 168cfd198b..69f13e401b 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_list.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_list.py index cb88c38e4e..4dcedf2fb1 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_list.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_spec.py b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_spec.py index cf9bea23c8..b1dc34dcf9 100644 --- a/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_spec.py +++ b/kubernetes/aio/client/models/v1beta1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_mutation.py b/kubernetes/aio/client/models/v1beta1_mutation.py index 1dd81bfd2b..ec43ae4505 100644 --- a/kubernetes/aio/client/models/v1beta1_mutation.py +++ b/kubernetes/aio/client/models/v1beta1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Mutation(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_named_rule_with_operations.py b/kubernetes/aio/client/models/v1beta1_named_rule_with_operations.py index 57ba13d150..4878cc5c0c 100644 --- a/kubernetes/aio/client/models/v1beta1_named_rule_with_operations.py +++ b/kubernetes/aio/client/models/v1beta1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_network_device_data.py b/kubernetes/aio/client/models/v1beta1_network_device_data.py index 7e345bb780..5d4dca413f 100644 --- a/kubernetes/aio/client/models/v1beta1_network_device_data.py +++ b/kubernetes/aio/client/models/v1beta1_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NetworkDeviceData(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_node_allocatable_mapping.py b/kubernetes/aio/client/models/v1beta1_node_allocatable_mapping.py index a74fe9a6c4..829093a547 100644 --- a/kubernetes/aio/client/models/v1beta1_node_allocatable_mapping.py +++ b/kubernetes/aio/client/models/v1beta1_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_node_allocatable_overhead.py b/kubernetes/aio/client/models/v1beta1_node_allocatable_overhead.py index 80fe64b5f1..ac2a412736 100644 --- a/kubernetes/aio/client/models/v1beta1_node_allocatable_overhead.py +++ b/kubernetes/aio/client/models/v1beta1_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_node_allocatable_resource.py b/kubernetes/aio/client/models/v1beta1_node_allocatable_resource.py index 6577c15a00..e8b37f1cfa 100644 --- a/kubernetes/aio/client/models/v1beta1_node_allocatable_resource.py +++ b/kubernetes/aio/client/models/v1beta1_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableResource(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_opaque_device_configuration.py b/kubernetes/aio/client/models/v1beta1_opaque_device_configuration.py index b2aaf6d194..8048d586d0 100644 --- a/kubernetes/aio/client/models/v1beta1_opaque_device_configuration.py +++ b/kubernetes/aio/client/models/v1beta1_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_param_kind.py b/kubernetes/aio/client/models/v1beta1_param_kind.py index f69cf31720..8be9912679 100644 --- a/kubernetes/aio/client/models/v1beta1_param_kind.py +++ b/kubernetes/aio/client/models/v1beta1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ParamKind(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_param_ref.py b/kubernetes/aio/client/models/v1beta1_param_ref.py index 70fe282be8..144ff53480 100644 --- a/kubernetes/aio/client/models/v1beta1_param_ref.py +++ b/kubernetes/aio/client/models/v1beta1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ParamRef(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_certificate_request.py b/kubernetes/aio/client/models/v1beta1_pod_certificate_request.py index ae355aadc9..30140c1b63 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_certificate_request.py +++ b/kubernetes/aio/client/models/v1beta1_pod_certificate_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_list.py b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_list.py index 438f7840b5..75a7d6e7fc 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_list.py +++ b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_spec.py b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_spec.py index 369ba16099..4d77cb1928 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_spec.py +++ b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_status.py b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_status.py index b64256c5f1..c5d42234b2 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_certificate_request_status.py +++ b/kubernetes/aio/client/models/v1beta1_pod_certificate_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group.py b/kubernetes/aio/client/models/v1beta1_pod_group.py index e67f53f25d..bb7cb444dd 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroup(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_list.py b/kubernetes/aio/client/models/v1beta1_pod_group_list.py index 88b774c73b..7c7dfa0882 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_list.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim.py b/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim.py index 81ad4597e5..63a794ed3e 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim_status.py b/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim_status.py index 42ef3bc9be..1f0d8e5845 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_constraints.py b/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_constraints.py index 4338298d36..122adff0cd 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_constraints.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_policy.py b/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_policy.py index 52168bc351..7c55e2afc5 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_policy.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_spec.py b/kubernetes/aio/client/models/v1beta1_pod_group_spec.py index 1f6042922b..abeb127f35 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_spec.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_status.py b/kubernetes/aio/client/models/v1beta1_pod_group_status.py index 9feb393263..579a4081f3 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_status.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_pod_group_template.py b/kubernetes/aio/client/models/v1beta1_pod_group_template.py index fd31d942d8..e264b2d303 100644 --- a/kubernetes/aio/client/models/v1beta1_pod_group_template.py +++ b/kubernetes/aio/client/models/v1beta1_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim.py b/kubernetes/aio/client/models/v1beta1_resource_claim.py index d17759f584..eb87b8b339 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_consumer_reference.py b/kubernetes/aio/client/models/v1beta1_resource_claim_consumer_reference.py index 032257051d..a24ba86a85 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_consumer_reference.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_list.py b/kubernetes/aio/client/models/v1beta1_resource_claim_list.py index e5216ea966..b2b4cec8ab 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_list.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_spec.py b/kubernetes/aio/client/models/v1beta1_resource_claim_spec.py index 311cd55287..d39c8e1896 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_spec.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_status.py b/kubernetes/aio/client/models/v1beta1_resource_claim_status.py index bedfdd56b7..cae09e44cf 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_template.py b/kubernetes/aio/client/models/v1beta1_resource_claim_template.py index 4dc2d618a5..bfd0ce63cb 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_template.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_template_list.py b/kubernetes/aio/client/models/v1beta1_resource_claim_template_list.py index ceeb27351a..6819c59f4d 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_template_list.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_claim_template_spec.py b/kubernetes/aio/client/models/v1beta1_resource_claim_template_spec.py index 921490bfbd..2baf08b522 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_claim_template_spec.py +++ b/kubernetes/aio/client/models/v1beta1_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_pool.py b/kubernetes/aio/client/models/v1beta1_resource_pool.py index b0bb16ef38..765c4af78b 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_pool.py +++ b/kubernetes/aio/client/models/v1beta1_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourcePool(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_slice.py b/kubernetes/aio/client/models/v1beta1_resource_slice.py index 5e5ac0868f..64b4a3915a 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_slice.py +++ b/kubernetes/aio/client/models/v1beta1_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSlice(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_slice_list.py b/kubernetes/aio/client/models/v1beta1_resource_slice_list.py index 87b3d7f2f1..bcd725376a 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_slice_list.py +++ b/kubernetes/aio/client/models/v1beta1_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSliceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_resource_slice_spec.py b/kubernetes/aio/client/models/v1beta1_resource_slice_spec.py index 089413b292..dba20fda1d 100644 --- a/kubernetes/aio/client/models/v1beta1_resource_slice_spec.py +++ b/kubernetes/aio/client/models/v1beta1_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSliceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_storage_version_migration.py b/kubernetes/aio/client/models/v1beta1_storage_version_migration.py index 1a6d36256e..58aeea4bd4 100644 --- a/kubernetes/aio/client/models/v1beta1_storage_version_migration.py +++ b/kubernetes/aio/client/models/v1beta1_storage_version_migration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_storage_version_migration_list.py b/kubernetes/aio/client/models/v1beta1_storage_version_migration_list.py index ca86a0bd39..a98f880d21 100644 --- a/kubernetes/aio/client/models/v1beta1_storage_version_migration_list.py +++ b/kubernetes/aio/client/models/v1beta1_storage_version_migration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_storage_version_migration_spec.py b/kubernetes/aio/client/models/v1beta1_storage_version_migration_spec.py index 0574ed332e..db16653db4 100644 --- a/kubernetes/aio/client/models/v1beta1_storage_version_migration_spec.py +++ b/kubernetes/aio/client/models/v1beta1_storage_version_migration_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_storage_version_migration_status.py b/kubernetes/aio/client/models/v1beta1_storage_version_migration_status.py index 1dc5c9bbdb..383de54a40 100644 --- a/kubernetes/aio/client/models/v1beta1_storage_version_migration_status.py +++ b/kubernetes/aio/client/models/v1beta1_storage_version_migration_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_topology_constraint.py b/kubernetes/aio/client/models/v1beta1_topology_constraint.py index 485d583df7..fcb3ae045c 100644 --- a/kubernetes/aio/client/models/v1beta1_topology_constraint.py +++ b/kubernetes/aio/client/models/v1beta1_topology_constraint.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1TopologyConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_typed_local_object_reference.py b/kubernetes/aio/client/models/v1beta1_typed_local_object_reference.py index 3dbc8a3c30..f8a8476ba5 100644 --- a/kubernetes/aio/client/models/v1beta1_typed_local_object_reference.py +++ b/kubernetes/aio/client/models/v1beta1_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_variable.py b/kubernetes/aio/client/models/v1beta1_variable.py index 8032748b70..4503ae4758 100644 --- a/kubernetes/aio/client/models/v1beta1_variable.py +++ b/kubernetes/aio/client/models/v1beta1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Variable(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_workload.py b/kubernetes/aio/client/models/v1beta1_workload.py index 7974f2ff60..aea45b38e5 100644 --- a/kubernetes/aio/client/models/v1beta1_workload.py +++ b/kubernetes/aio/client/models/v1beta1_workload.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Workload(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_workload_list.py b/kubernetes/aio/client/models/v1beta1_workload_list.py index dc59622c27..d9a724945a 100644 --- a/kubernetes/aio/client/models/v1beta1_workload_list.py +++ b/kubernetes/aio/client/models/v1beta1_workload_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_workload_reference.py b/kubernetes/aio/client/models/v1beta1_workload_reference.py index 0533003e8b..a4743ea4d8 100644 --- a/kubernetes/aio/client/models/v1beta1_workload_reference.py +++ b/kubernetes/aio/client/models/v1beta1_workload_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta1_workload_spec.py b/kubernetes/aio/client/models/v1beta1_workload_spec.py index 486a7fd31a..550dbc5a4a 100644 --- a/kubernetes/aio/client/models/v1beta1_workload_spec.py +++ b/kubernetes/aio/client/models/v1beta1_workload_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_allocated_device_status.py b/kubernetes/aio/client/models/v1beta2_allocated_device_status.py index b3d9731e53..6d50620328 100644 --- a/kubernetes/aio/client/models/v1beta2_allocated_device_status.py +++ b/kubernetes/aio/client/models/v1beta2_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_allocation_result.py b/kubernetes/aio/client/models/v1beta2_allocation_result.py index 9ced4b063c..494739c940 100644 --- a/kubernetes/aio/client/models/v1beta2_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta2_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2AllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_capacity_request_policy.py b/kubernetes/aio/client/models/v1beta2_capacity_request_policy.py index 0175208ce0..ebccfb7e03 100644 --- a/kubernetes/aio/client/models/v1beta2_capacity_request_policy.py +++ b/kubernetes/aio/client/models/v1beta2_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_capacity_request_policy_range.py b/kubernetes/aio/client/models/v1beta2_capacity_request_policy_range.py index cd0991acb2..eca129fabe 100644 --- a/kubernetes/aio/client/models/v1beta2_capacity_request_policy_range.py +++ b/kubernetes/aio/client/models/v1beta2_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_capacity_requirements.py b/kubernetes/aio/client/models/v1beta2_capacity_requirements.py index f022787f19..39f73667bb 100644 --- a/kubernetes/aio/client/models/v1beta2_capacity_requirements.py +++ b/kubernetes/aio/client/models/v1beta2_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequirements(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_cel_device_selector.py b/kubernetes/aio/client/models/v1beta2_cel_device_selector.py index 68c3e4b754..be76d376a1 100644 --- a/kubernetes/aio/client/models/v1beta2_cel_device_selector.py +++ b/kubernetes/aio/client/models/v1beta2_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CELDeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_counter.py b/kubernetes/aio/client/models/v1beta2_counter.py index acb85de86f..306bacab85 100644 --- a/kubernetes/aio/client/models/v1beta2_counter.py +++ b/kubernetes/aio/client/models/v1beta2_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2Counter(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_counter_set.py b/kubernetes/aio/client/models/v1beta2_counter_set.py index 2f9e300c35..8a4db4ba06 100644 --- a/kubernetes/aio/client/models/v1beta2_counter_set.py +++ b/kubernetes/aio/client/models/v1beta2_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CounterSet(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device.py b/kubernetes/aio/client/models/v1beta2_device.py index 9349382495..95756daa80 100644 --- a/kubernetes/aio/client/models/v1beta2_device.py +++ b/kubernetes/aio/client/models/v1beta2_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2Device(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_allocation_configuration.py b/kubernetes/aio/client/models/v1beta2_device_allocation_configuration.py index bbdf2c8974..80b28feea4 100644 --- a/kubernetes/aio/client/models/v1beta2_device_allocation_configuration.py +++ b/kubernetes/aio/client/models/v1beta2_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_allocation_result.py b/kubernetes/aio/client/models/v1beta2_device_allocation_result.py index 398f40d592..3af17c81ac 100644 --- a/kubernetes/aio/client/models/v1beta2_device_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta2_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_attribute.py b/kubernetes/aio/client/models/v1beta2_device_attribute.py index 63731b1e16..b415d55f72 100644 --- a/kubernetes/aio/client/models/v1beta2_device_attribute.py +++ b/kubernetes/aio/client/models/v1beta2_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_capacity.py b/kubernetes/aio/client/models/v1beta2_device_capacity.py index 8e9d40da0a..1069d62b54 100644 --- a/kubernetes/aio/client/models/v1beta2_device_capacity.py +++ b/kubernetes/aio/client/models/v1beta2_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceCapacity(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_claim.py b/kubernetes/aio/client/models/v1beta2_device_claim.py index ca5987027b..b3977a6d47 100644 --- a/kubernetes/aio/client/models/v1beta2_device_claim.py +++ b/kubernetes/aio/client/models/v1beta2_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_claim_configuration.py b/kubernetes/aio/client/models/v1beta2_device_claim_configuration.py index 6707188459..d82a05edfa 100644 --- a/kubernetes/aio/client/models/v1beta2_device_claim_configuration.py +++ b/kubernetes/aio/client/models/v1beta2_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_class.py b/kubernetes/aio/client/models/v1beta2_device_class.py index 3382528d55..6feac42919 100644 --- a/kubernetes/aio/client/models/v1beta2_device_class.py +++ b/kubernetes/aio/client/models/v1beta2_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClass(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_class_configuration.py b/kubernetes/aio/client/models/v1beta2_device_class_configuration.py index f584085f80..368276e96d 100644 --- a/kubernetes/aio/client/models/v1beta2_device_class_configuration.py +++ b/kubernetes/aio/client/models/v1beta2_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_class_list.py b/kubernetes/aio/client/models/v1beta2_device_class_list.py index dc85c7e010..e1c313796b 100644 --- a/kubernetes/aio/client/models/v1beta2_device_class_list.py +++ b/kubernetes/aio/client/models/v1beta2_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_class_spec.py b/kubernetes/aio/client/models/v1beta2_device_class_spec.py index 43345fa1a7..953aa74caf 100644 --- a/kubernetes/aio/client/models/v1beta2_device_class_spec.py +++ b/kubernetes/aio/client/models/v1beta2_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_constraint.py b/kubernetes/aio/client/models/v1beta2_device_constraint.py index 65d1b3dd67..3e37109660 100644 --- a/kubernetes/aio/client/models/v1beta2_device_constraint.py +++ b/kubernetes/aio/client/models/v1beta2_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceConstraint(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_counter_consumption.py b/kubernetes/aio/client/models/v1beta2_device_counter_consumption.py index c1cbcff6e4..b67cefe6e4 100644 --- a/kubernetes/aio/client/models/v1beta2_device_counter_consumption.py +++ b/kubernetes/aio/client/models/v1beta2_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_derived_attribute.py b/kubernetes/aio/client/models/v1beta2_device_derived_attribute.py index 84ffb3c5fd..a9c6b2f2fd 100644 --- a/kubernetes/aio/client/models/v1beta2_device_derived_attribute.py +++ b/kubernetes/aio/client/models/v1beta2_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_request.py b/kubernetes/aio/client/models/v1beta2_device_request.py index 53189d98d4..7cdf74dd21 100644 --- a/kubernetes/aio/client/models/v1beta2_device_request.py +++ b/kubernetes/aio/client/models/v1beta2_device_request.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_request_allocation_result.py b/kubernetes/aio/client/models/v1beta2_device_request_allocation_result.py index 06e5150727..2919aee484 100644 --- a/kubernetes/aio/client/models/v1beta2_device_request_allocation_result.py +++ b/kubernetes/aio/client/models/v1beta2_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_selector.py b/kubernetes/aio/client/models/v1beta2_device_selector.py index 6ea46301a7..2c98ea17f4 100644 --- a/kubernetes/aio/client/models/v1beta2_device_selector.py +++ b/kubernetes/aio/client/models/v1beta2_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_sub_request.py b/kubernetes/aio/client/models/v1beta2_device_sub_request.py index fa32ec4a6d..db92b3a7f0 100644 --- a/kubernetes/aio/client/models/v1beta2_device_sub_request.py +++ b/kubernetes/aio/client/models/v1beta2_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceSubRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint.py b/kubernetes/aio/client/models/v1beta2_device_taint.py index dd5e80ec63..dc8874bc25 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaint(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint_rule.py b/kubernetes/aio/client/models/v1beta2_device_taint_rule.py index 484d5b2ca8..9b9dfe8775 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint_rule.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRule(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint_rule_list.py b/kubernetes/aio/client/models/v1beta2_device_taint_rule_list.py index 1898d8136b..2247c2c285 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint_rule_list.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint_rule_spec.py b/kubernetes/aio/client/models/v1beta2_device_taint_rule_spec.py index 70c54b81b4..585c9ca4bd 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint_rule_spec.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint_rule_status.py b/kubernetes/aio/client/models/v1beta2_device_taint_rule_status.py index 86097b3ebb..9c2e09d847 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint_rule_status.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_taint_selector.py b/kubernetes/aio/client/models/v1beta2_device_taint_selector.py index 15b5dbb0b7..273d62adf5 100644 --- a/kubernetes/aio/client/models/v1beta2_device_taint_selector.py +++ b/kubernetes/aio/client/models/v1beta2_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintSelector(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_device_toleration.py b/kubernetes/aio/client/models/v1beta2_device_toleration.py index 65310dac84..21c814a8a4 100644 --- a/kubernetes/aio/client/models/v1beta2_device_toleration.py +++ b/kubernetes/aio/client/models/v1beta2_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceToleration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_exact_device_request.py b/kubernetes/aio/client/models/v1beta2_exact_device_request.py index cb2d9c97a0..961d9de84f 100644 --- a/kubernetes/aio/client/models/v1beta2_exact_device_request.py +++ b/kubernetes/aio/client/models/v1beta2_exact_device_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ExactDeviceRequest(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_network_device_data.py b/kubernetes/aio/client/models/v1beta2_network_device_data.py index d537e52a2a..5c80be15be 100644 --- a/kubernetes/aio/client/models/v1beta2_network_device_data.py +++ b/kubernetes/aio/client/models/v1beta2_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NetworkDeviceData(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_node_allocatable_mapping.py b/kubernetes/aio/client/models/v1beta2_node_allocatable_mapping.py index bfccf5c3ba..02de894734 100644 --- a/kubernetes/aio/client/models/v1beta2_node_allocatable_mapping.py +++ b/kubernetes/aio/client/models/v1beta2_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_node_allocatable_overhead.py b/kubernetes/aio/client/models/v1beta2_node_allocatable_overhead.py index 7d24dc807b..a8b4d6b7e1 100644 --- a/kubernetes/aio/client/models/v1beta2_node_allocatable_overhead.py +++ b/kubernetes/aio/client/models/v1beta2_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_node_allocatable_resource.py b/kubernetes/aio/client/models/v1beta2_node_allocatable_resource.py index e05d540821..e279f47d2e 100644 --- a/kubernetes/aio/client/models/v1beta2_node_allocatable_resource.py +++ b/kubernetes/aio/client/models/v1beta2_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableResource(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_opaque_device_configuration.py b/kubernetes/aio/client/models/v1beta2_opaque_device_configuration.py index a13fa32102..13d705b898 100644 --- a/kubernetes/aio/client/models/v1beta2_opaque_device_configuration.py +++ b/kubernetes/aio/client/models/v1beta2_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim.py b/kubernetes/aio/client/models/v1beta2_resource_claim.py index 4c7cdbcc26..a171f07fb9 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaim(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_consumer_reference.py b/kubernetes/aio/client/models/v1beta2_resource_claim_consumer_reference.py index 848f7e1b4c..46956b4946 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_consumer_reference.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_list.py b/kubernetes/aio/client/models/v1beta2_resource_claim_list.py index e253a3bb54..5c62b48e82 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_list.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_spec.py b/kubernetes/aio/client/models/v1beta2_resource_claim_spec.py index 81baf80771..11dfc1dbb8 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_spec.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_status.py b/kubernetes/aio/client/models/v1beta2_resource_claim_status.py index 8e9c1045a5..804330a2ab 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_status.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_template.py b/kubernetes/aio/client/models/v1beta2_resource_claim_template.py index e004cc1dd8..3878c540d1 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_template.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_template_list.py b/kubernetes/aio/client/models/v1beta2_resource_claim_template_list.py index 394addfdd3..d1e73b2ba1 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_template_list.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_claim_template_spec.py b/kubernetes/aio/client/models/v1beta2_resource_claim_template_spec.py index 9f439ad601..3109e733ca 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_claim_template_spec.py +++ b/kubernetes/aio/client/models/v1beta2_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_pool.py b/kubernetes/aio/client/models/v1beta2_resource_pool.py index a26e4a6ec4..0a64e94d23 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_pool.py +++ b/kubernetes/aio/client/models/v1beta2_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourcePool(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_slice.py b/kubernetes/aio/client/models/v1beta2_resource_slice.py index e717d8fadf..f1868012b8 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_slice.py +++ b/kubernetes/aio/client/models/v1beta2_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSlice(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_slice_list.py b/kubernetes/aio/client/models/v1beta2_resource_slice_list.py index 71cfe3c462..965b92bac4 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_slice_list.py +++ b/kubernetes/aio/client/models/v1beta2_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSliceList(BaseModel): diff --git a/kubernetes/aio/client/models/v1beta2_resource_slice_spec.py b/kubernetes/aio/client/models/v1beta2_resource_slice_spec.py index eb637a0324..a72a268f5b 100644 --- a/kubernetes/aio/client/models/v1beta2_resource_slice_spec.py +++ b/kubernetes/aio/client/models/v1beta2_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSliceSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v2_api_group_discovery.py b/kubernetes/aio/client/models/v2_api_group_discovery.py index a25f9dd233..a27982522e 100644 --- a/kubernetes/aio/client/models/v2_api_group_discovery.py +++ b/kubernetes/aio/client/models/v2_api_group_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIGroupDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2_api_group_discovery_list.py b/kubernetes/aio/client/models/v2_api_group_discovery_list.py index 248c383efe..8464d972ad 100644 --- a/kubernetes/aio/client/models/v2_api_group_discovery_list.py +++ b/kubernetes/aio/client/models/v2_api_group_discovery_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIGroupDiscoveryList(BaseModel): diff --git a/kubernetes/aio/client/models/v2_api_resource_discovery.py b/kubernetes/aio/client/models/v2_api_resource_discovery.py index 5c9178c3ab..d4d097214c 100644 --- a/kubernetes/aio/client/models/v2_api_resource_discovery.py +++ b/kubernetes/aio/client/models/v2_api_resource_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIResourceDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2_api_subresource_discovery.py b/kubernetes/aio/client/models/v2_api_subresource_discovery.py index ef567728a9..0425f580aa 100644 --- a/kubernetes/aio/client/models/v2_api_subresource_discovery.py +++ b/kubernetes/aio/client/models/v2_api_subresource_discovery.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APISubresourceDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2_api_version_discovery.py b/kubernetes/aio/client/models/v2_api_version_discovery.py index d1669850c7..bfb46dea1b 100644 --- a/kubernetes/aio/client/models/v2_api_version_discovery.py +++ b/kubernetes/aio/client/models/v2_api_version_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIVersionDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2_container_resource_metric_source.py b/kubernetes/aio/client/models/v2_container_resource_metric_source.py index 67cb95ff2a..35bb23a322 100644 --- a/kubernetes/aio/client/models/v2_container_resource_metric_source.py +++ b/kubernetes/aio/client/models/v2_container_resource_metric_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ContainerResourceMetricSource(BaseModel): diff --git a/kubernetes/aio/client/models/v2_container_resource_metric_status.py b/kubernetes/aio/client/models/v2_container_resource_metric_status.py index 27d03fbf6b..06839d204d 100644 --- a/kubernetes/aio/client/models/v2_container_resource_metric_status.py +++ b/kubernetes/aio/client/models/v2_container_resource_metric_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ContainerResourceMetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_cross_version_object_reference.py b/kubernetes/aio/client/models/v2_cross_version_object_reference.py index ba81fd1d72..433d46923b 100644 --- a/kubernetes/aio/client/models/v2_cross_version_object_reference.py +++ b/kubernetes/aio/client/models/v2_cross_version_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2CrossVersionObjectReference(BaseModel): diff --git a/kubernetes/aio/client/models/v2_external_metric_source.py b/kubernetes/aio/client/models/v2_external_metric_source.py index 9351df83c2..7725ed4994 100644 --- a/kubernetes/aio/client/models/v2_external_metric_source.py +++ b/kubernetes/aio/client/models/v2_external_metric_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ExternalMetricSource(BaseModel): diff --git a/kubernetes/aio/client/models/v2_external_metric_status.py b/kubernetes/aio/client/models/v2_external_metric_status.py index ef1a7e5aff..726db96227 100644 --- a/kubernetes/aio/client/models/v2_external_metric_status.py +++ b/kubernetes/aio/client/models/v2_external_metric_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ExternalMetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler.py index 464493ecaf..9a4e6d566e 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscaler(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_behavior.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_behavior.py index c1e9e39f45..1e3864bbcf 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_behavior.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_behavior.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerBehavior(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_condition.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_condition.py index 939ebf388f..8d00dbef5e 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_condition.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerCondition(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_list.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_list.py index 1a4d0ade44..28a0a985d5 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_list.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerList(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_spec.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_spec.py index 30002a6593..f33a691d34 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_spec.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_status.py b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_status.py index e803cc587a..2fd5392824 100644 --- a/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_status.py +++ b/kubernetes/aio/client/models/v2_horizontal_pod_autoscaler_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_hpa_scaling_policy.py b/kubernetes/aio/client/models/v2_hpa_scaling_policy.py index 8e63e1a4a5..17890baffc 100644 --- a/kubernetes/aio/client/models/v2_hpa_scaling_policy.py +++ b/kubernetes/aio/client/models/v2_hpa_scaling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HPAScalingPolicy(BaseModel): diff --git a/kubernetes/aio/client/models/v2_hpa_scaling_rules.py b/kubernetes/aio/client/models/v2_hpa_scaling_rules.py index 95fd66a890..e945ee8dfa 100644 --- a/kubernetes/aio/client/models/v2_hpa_scaling_rules.py +++ b/kubernetes/aio/client/models/v2_hpa_scaling_rules.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HPAScalingRules(BaseModel): diff --git a/kubernetes/aio/client/models/v2_metric_identifier.py b/kubernetes/aio/client/models/v2_metric_identifier.py index 2e5c691460..f96ed20664 100644 --- a/kubernetes/aio/client/models/v2_metric_identifier.py +++ b/kubernetes/aio/client/models/v2_metric_identifier.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricIdentifier(BaseModel): diff --git a/kubernetes/aio/client/models/v2_metric_spec.py b/kubernetes/aio/client/models/v2_metric_spec.py index f294b2440c..39ac9529bb 100644 --- a/kubernetes/aio/client/models/v2_metric_spec.py +++ b/kubernetes/aio/client/models/v2_metric_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricSpec(BaseModel): diff --git a/kubernetes/aio/client/models/v2_metric_status.py b/kubernetes/aio/client/models/v2_metric_status.py index a2c5a42971..6870545d89 100644 --- a/kubernetes/aio/client/models/v2_metric_status.py +++ b/kubernetes/aio/client/models/v2_metric_status.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_metric_target.py b/kubernetes/aio/client/models/v2_metric_target.py index cd5c47b8d0..bd91db7b23 100644 --- a/kubernetes/aio/client/models/v2_metric_target.py +++ b/kubernetes/aio/client/models/v2_metric_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricTarget(BaseModel): diff --git a/kubernetes/aio/client/models/v2_metric_value_status.py b/kubernetes/aio/client/models/v2_metric_value_status.py index b3fe5b4ca7..2ca1da58ff 100644 --- a/kubernetes/aio/client/models/v2_metric_value_status.py +++ b/kubernetes/aio/client/models/v2_metric_value_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricValueStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_object_metric_source.py b/kubernetes/aio/client/models/v2_object_metric_source.py index 2cf04477cf..9ee560407f 100644 --- a/kubernetes/aio/client/models/v2_object_metric_source.py +++ b/kubernetes/aio/client/models/v2_object_metric_source.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ObjectMetricSource(BaseModel): diff --git a/kubernetes/aio/client/models/v2_object_metric_status.py b/kubernetes/aio/client/models/v2_object_metric_status.py index 4002d71b1f..edb4e9f817 100644 --- a/kubernetes/aio/client/models/v2_object_metric_status.py +++ b/kubernetes/aio/client/models/v2_object_metric_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ObjectMetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_pods_metric_source.py b/kubernetes/aio/client/models/v2_pods_metric_source.py index 85e9caff92..200461f064 100644 --- a/kubernetes/aio/client/models/v2_pods_metric_source.py +++ b/kubernetes/aio/client/models/v2_pods_metric_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2PodsMetricSource(BaseModel): diff --git a/kubernetes/aio/client/models/v2_pods_metric_status.py b/kubernetes/aio/client/models/v2_pods_metric_status.py index d698edebae..7a6befe139 100644 --- a/kubernetes/aio/client/models/v2_pods_metric_status.py +++ b/kubernetes/aio/client/models/v2_pods_metric_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2PodsMetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2_resource_metric_source.py b/kubernetes/aio/client/models/v2_resource_metric_source.py index 463341bb20..743c9b2da1 100644 --- a/kubernetes/aio/client/models/v2_resource_metric_source.py +++ b/kubernetes/aio/client/models/v2_resource_metric_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ResourceMetricSource(BaseModel): diff --git a/kubernetes/aio/client/models/v2_resource_metric_status.py b/kubernetes/aio/client/models/v2_resource_metric_status.py index 6317e7fe73..79a76dcac4 100644 --- a/kubernetes/aio/client/models/v2_resource_metric_status.py +++ b/kubernetes/aio/client/models/v2_resource_metric_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ResourceMetricStatus(BaseModel): diff --git a/kubernetes/aio/client/models/v2beta1_api_group_discovery.py b/kubernetes/aio/client/models/v2beta1_api_group_discovery.py index 1d63a6bf3d..b021a03c5c 100644 --- a/kubernetes/aio/client/models/v2beta1_api_group_discovery.py +++ b/kubernetes/aio/client/models/v2beta1_api_group_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIGroupDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2beta1_api_group_discovery_list.py b/kubernetes/aio/client/models/v2beta1_api_group_discovery_list.py index d08b2dd66e..0c5a36bf00 100644 --- a/kubernetes/aio/client/models/v2beta1_api_group_discovery_list.py +++ b/kubernetes/aio/client/models/v2beta1_api_group_discovery_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIGroupDiscoveryList(BaseModel): diff --git a/kubernetes/aio/client/models/v2beta1_api_resource_discovery.py b/kubernetes/aio/client/models/v2beta1_api_resource_discovery.py index 8d19e379cb..84f2ecfadf 100644 --- a/kubernetes/aio/client/models/v2beta1_api_resource_discovery.py +++ b/kubernetes/aio/client/models/v2beta1_api_resource_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIResourceDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2beta1_api_subresource_discovery.py b/kubernetes/aio/client/models/v2beta1_api_subresource_discovery.py index b52615943d..560706ef64 100644 --- a/kubernetes/aio/client/models/v2beta1_api_subresource_discovery.py +++ b/kubernetes/aio/client/models/v2beta1_api_subresource_discovery.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APISubresourceDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/v2beta1_api_version_discovery.py b/kubernetes/aio/client/models/v2beta1_api_version_discovery.py index 9d4b98f984..dfe477bb81 100644 --- a/kubernetes/aio/client/models/v2beta1_api_version_discovery.py +++ b/kubernetes/aio/client/models/v2beta1_api_version_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIVersionDiscovery(BaseModel): diff --git a/kubernetes/aio/client/models/version_info.py b/kubernetes/aio/client/models/version_info.py index d31a9841ba..0b56f4e14d 100644 --- a/kubernetes/aio/client/models/version_info.py +++ b/kubernetes/aio/client/models/version_info.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.aio.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class VersionInfo(BaseModel): diff --git a/kubernetes/aio/client/rest.py b/kubernetes/aio/client/rest.py index 4c07faa125..14154cc00b 100644 --- a/kubernetes/aio/client/rest.py +++ b/kubernetes/aio/client/rest.py @@ -20,6 +20,7 @@ import aiohttp import aiohttp_retry +from multidict import CIMultiDict from kubernetes.aio.utils.retry import ( is_retry_after_response, @@ -203,7 +204,7 @@ async def request( ) post_params = post_params or {} - headers = headers or {} + headers = CIMultiDict(headers or {}) # url already contains the URL query string timeout = _request_timeout or 5 * 60 diff --git a/kubernetes/client/_legacy_model_helpers.py b/kubernetes/client/_legacy_model_helpers.py new file mode 100644 index 0000000000..24d63d6111 --- /dev/null +++ b/kubernetes/client/_legacy_model_helpers.py @@ -0,0 +1,80 @@ +""" + Kubernetes + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: release-1.37 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from typing import Any + +_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" + + +def _get_openapi_to_dict(value: Any) -> Any: + # Reciprocal function references preserve inherited generated methods + # without reserving model member names. Checking both directions also + # rejects overrides whose decorators copy function attributes. + to_dict = getattr(value, "to_dict", None) + type_to_dict = getattr(type(value), "to_dict", None) + if ( + not callable(to_dict) + or getattr(to_dict, "__func__", None) is not type_to_dict + ): + return None + + openapi_to_dict = getattr( + type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None + ) + if ( + not callable(openapi_to_dict) + or getattr( + openapi_to_dict, + _OPENAPI_GENERATOR_TO_DICT, + None, + ) is not type_to_dict + ): + return None + return openapi_to_dict + + +def _to_legacy_item(value: Any, serialize: bool) -> Any: + to_dict = getattr(value, "to_dict", None) + if _get_openapi_to_dict(value) is not None and callable(to_dict): + return to_dict(serialize=serialize) + if callable(to_dict): + return to_dict() + return value + + +def _to_legacy_value(value: Any, serialize: bool) -> Any: + # python-legacy converted only immediate list elements or dictionary values: + # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 + if isinstance(value, list): + return [_to_legacy_item(item, serialize) for item in value] + if isinstance(value, dict): + return { + key: _to_legacy_item(item, serialize) + for key, item in value.items() + } + return _to_legacy_item(value, serialize) + + +def _to_openapi_value(value: Any) -> Any: + if isinstance(value, list): + return [_to_openapi_value(item) for item in value] + if isinstance(value, dict): + return {key: _to_openapi_value(item) for key, item in value.items()} + + to_openapi_dict = _get_openapi_to_dict(value) + if to_openapi_dict is not None: + return to_openapi_dict(value) + + to_dict = getattr(value, "to_dict", None) + if callable(to_dict): + return to_dict() + return value diff --git a/kubernetes/client/api/admissionregistration_api.py b/kubernetes/client/api/admissionregistration_api.py index e71d1c3f78..6492ccf60f 100644 --- a/kubernetes/client/api/admissionregistration_api.py +++ b/kubernetes/client/api/admissionregistration_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/admissionregistration_v1_api.py b/kubernetes/client/api/admissionregistration_v1_api.py index f63e51b548..4979c569ed 100644 --- a/kubernetes/client/api/admissionregistration_v1_api.py +++ b/kubernetes/client/api/admissionregistration_v1_api.py @@ -286,7 +286,7 @@ def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -319,7 +319,7 @@ def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -567,7 +567,7 @@ def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -600,7 +600,7 @@ def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -848,7 +848,7 @@ def _create_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -881,7 +881,7 @@ def _create_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1129,7 +1129,7 @@ def _create_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1162,7 +1162,7 @@ def _create_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1410,7 +1410,7 @@ def _create_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1443,7 +1443,7 @@ def _create_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1691,7 +1691,7 @@ def _create_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1724,7 +1724,7 @@ def _create_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2067,7 +2067,7 @@ def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2144,7 +2144,7 @@ def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2487,7 +2487,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2564,7 +2564,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2907,7 +2907,7 @@ def _delete_collection_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2984,7 +2984,7 @@ def _delete_collection_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3327,7 +3327,7 @@ def _delete_collection_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3404,7 +3404,7 @@ def _delete_collection_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3747,7 +3747,7 @@ def _delete_collection_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3824,7 +3824,7 @@ def _delete_collection_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4167,7 +4167,7 @@ def _delete_collection_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4244,7 +4244,7 @@ def _delete_collection_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4517,7 +4517,7 @@ def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4560,7 +4560,7 @@ def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4833,7 +4833,7 @@ def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4876,7 +4876,7 @@ def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5149,7 +5149,7 @@ def _delete_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5192,7 +5192,7 @@ def _delete_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5465,7 +5465,7 @@ def _delete_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5508,7 +5508,7 @@ def _delete_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5781,7 +5781,7 @@ def _delete_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5824,7 +5824,7 @@ def _delete_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6097,7 +6097,7 @@ def _delete_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6140,7 +6140,7 @@ def _delete_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6339,7 +6339,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6354,7 +6354,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6661,7 +6661,7 @@ def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6724,7 +6724,7 @@ def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7034,7 +7034,7 @@ def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7097,7 +7097,7 @@ def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7407,7 +7407,7 @@ def _list_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7470,7 +7470,7 @@ def _list_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7780,7 +7780,7 @@ def _list_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7843,7 +7843,7 @@ def _list_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8153,7 +8153,7 @@ def _list_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8216,7 +8216,7 @@ def _list_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8526,7 +8526,7 @@ def _list_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8589,7 +8589,7 @@ def _list_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8856,7 +8856,7 @@ def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8895,7 +8895,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8907,7 +8907,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8921,7 +8921,7 @@ def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9176,7 +9176,7 @@ def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9215,7 +9215,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9227,7 +9227,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9241,7 +9241,7 @@ def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9496,7 +9496,7 @@ def _patch_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9535,7 +9535,7 @@ def _patch_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9547,7 +9547,7 @@ def _patch_mutating_webhook_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9561,7 +9561,7 @@ def _patch_mutating_webhook_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9816,7 +9816,7 @@ def _patch_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9855,7 +9855,7 @@ def _patch_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9867,7 +9867,7 @@ def _patch_validating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9881,7 +9881,7 @@ def _patch_validating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10136,7 +10136,7 @@ def _patch_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10175,7 +10175,7 @@ def _patch_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10187,7 +10187,7 @@ def _patch_validating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10201,7 +10201,7 @@ def _patch_validating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10456,7 +10456,7 @@ def _patch_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10495,7 +10495,7 @@ def _patch_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10507,7 +10507,7 @@ def _patch_validating_admission_policy_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10521,7 +10521,7 @@ def _patch_validating_admission_policy_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10776,7 +10776,7 @@ def _patch_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10815,7 +10815,7 @@ def _patch_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10827,7 +10827,7 @@ def _patch_validating_webhook_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10841,7 +10841,7 @@ def _patch_validating_webhook_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11049,7 +11049,7 @@ def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11070,7 +11070,7 @@ def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11287,7 +11287,7 @@ def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11308,7 +11308,7 @@ def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11525,7 +11525,7 @@ def _read_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11546,7 +11546,7 @@ def _read_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11763,7 +11763,7 @@ def _read_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11784,7 +11784,7 @@ def _read_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12001,7 +12001,7 @@ def _read_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12022,7 +12022,7 @@ def _read_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12239,7 +12239,7 @@ def _read_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12260,7 +12260,7 @@ def _read_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12477,7 +12477,7 @@ def _read_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12498,7 +12498,7 @@ def _read_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12753,7 +12753,7 @@ def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12788,7 +12788,7 @@ def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13043,7 +13043,7 @@ def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13078,7 +13078,7 @@ def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13333,7 +13333,7 @@ def _replace_mutating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13368,7 +13368,7 @@ def _replace_mutating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13623,7 +13623,7 @@ def _replace_validating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13658,7 +13658,7 @@ def _replace_validating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13913,7 +13913,7 @@ def _replace_validating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13948,7 +13948,7 @@ def _replace_validating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14203,7 +14203,7 @@ def _replace_validating_admission_policy_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14238,7 +14238,7 @@ def _replace_validating_admission_policy_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14493,7 +14493,7 @@ def _replace_validating_webhook_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14528,7 +14528,7 @@ def _replace_validating_webhook_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/admissionregistration_v1alpha1_api.py b/kubernetes/client/api/admissionregistration_v1alpha1_api.py index a19fe54453..6ff3a7fc4c 100644 --- a/kubernetes/client/api/admissionregistration_v1alpha1_api.py +++ b/kubernetes/client/api/admissionregistration_v1alpha1_api.py @@ -278,7 +278,7 @@ def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -559,7 +559,7 @@ def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -592,7 +592,7 @@ def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -935,7 +935,7 @@ def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1012,7 +1012,7 @@ def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1355,7 +1355,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1432,7 +1432,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1705,7 +1705,7 @@ def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1748,7 +1748,7 @@ def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2021,7 +2021,7 @@ def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2064,7 +2064,7 @@ def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2263,7 +2263,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2278,7 +2278,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2585,7 +2585,7 @@ def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2648,7 +2648,7 @@ def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2958,7 +2958,7 @@ def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3021,7 +3021,7 @@ def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3288,7 +3288,7 @@ def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3327,7 +3327,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3339,7 +3339,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3353,7 +3353,7 @@ def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3608,7 +3608,7 @@ def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3647,7 +3647,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3659,7 +3659,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3673,7 +3673,7 @@ def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3881,7 +3881,7 @@ def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3902,7 +3902,7 @@ def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4119,7 +4119,7 @@ def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4140,7 +4140,7 @@ def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4395,7 +4395,7 @@ def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4430,7 +4430,7 @@ def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4685,7 +4685,7 @@ def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4720,7 +4720,7 @@ def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/admissionregistration_v1beta1_api.py b/kubernetes/client/api/admissionregistration_v1beta1_api.py index 3354842758..f983cd7b51 100644 --- a/kubernetes/client/api/admissionregistration_v1beta1_api.py +++ b/kubernetes/client/api/admissionregistration_v1beta1_api.py @@ -278,7 +278,7 @@ def _create_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _create_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -559,7 +559,7 @@ def _create_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -592,7 +592,7 @@ def _create_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -935,7 +935,7 @@ def _delete_collection_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1012,7 +1012,7 @@ def _delete_collection_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1355,7 +1355,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1432,7 +1432,7 @@ def _delete_collection_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1705,7 +1705,7 @@ def _delete_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1748,7 +1748,7 @@ def _delete_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2021,7 +2021,7 @@ def _delete_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2064,7 +2064,7 @@ def _delete_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2263,7 +2263,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2278,7 +2278,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2585,7 +2585,7 @@ def _list_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2648,7 +2648,7 @@ def _list_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2958,7 +2958,7 @@ def _list_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3021,7 +3021,7 @@ def _list_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3288,7 +3288,7 @@ def _patch_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3327,7 +3327,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3339,7 +3339,7 @@ def _patch_mutating_admission_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3353,7 +3353,7 @@ def _patch_mutating_admission_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3608,7 +3608,7 @@ def _patch_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3647,7 +3647,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3659,7 +3659,7 @@ def _patch_mutating_admission_policy_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3673,7 +3673,7 @@ def _patch_mutating_admission_policy_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3881,7 +3881,7 @@ def _read_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3902,7 +3902,7 @@ def _read_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4119,7 +4119,7 @@ def _read_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4140,7 +4140,7 @@ def _read_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4395,7 +4395,7 @@ def _replace_mutating_admission_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4430,7 +4430,7 @@ def _replace_mutating_admission_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4685,7 +4685,7 @@ def _replace_mutating_admission_policy_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4720,7 +4720,7 @@ def _replace_mutating_admission_policy_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apiextensions_api.py b/kubernetes/client/api/apiextensions_api.py index defbc045a6..e9a13f6dfa 100644 --- a/kubernetes/client/api/apiextensions_api.py +++ b/kubernetes/client/api/apiextensions_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apiextensions_v1_api.py b/kubernetes/client/api/apiextensions_v1_api.py index d28b3028a6..dac70f9cc1 100644 --- a/kubernetes/client/api/apiextensions_v1_api.py +++ b/kubernetes/client/api/apiextensions_v1_api.py @@ -276,7 +276,7 @@ def _create_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_custom_resource_definition_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_custom_resource_definition_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2216,7 +2216,7 @@ def _patch_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2255,7 +2255,7 @@ def _patch_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2267,7 +2267,7 @@ def _patch_custom_resource_definition_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2281,7 +2281,7 @@ def _patch_custom_resource_definition_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2489,7 +2489,7 @@ def _read_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ def _read_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2727,7 +2727,7 @@ def _read_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2748,7 +2748,7 @@ def _read_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3003,7 +3003,7 @@ def _replace_custom_resource_definition_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3038,7 +3038,7 @@ def _replace_custom_resource_definition_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3293,7 +3293,7 @@ def _replace_custom_resource_definition_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3328,7 +3328,7 @@ def _replace_custom_resource_definition_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apiregistration_api.py b/kubernetes/client/api/apiregistration_api.py index ce032171da..7223f845f3 100644 --- a/kubernetes/client/api/apiregistration_api.py +++ b/kubernetes/client/api/apiregistration_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apiregistration_v1_api.py b/kubernetes/client/api/apiregistration_v1_api.py index c6d2e7ca7f..e286acde43 100644 --- a/kubernetes/client/api/apiregistration_v1_api.py +++ b/kubernetes/client/api/apiregistration_v1_api.py @@ -276,7 +276,7 @@ def _create_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -582,7 +582,7 @@ def _delete_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -625,7 +625,7 @@ def _delete_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -968,7 +968,7 @@ def _delete_collection_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_collection_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_api_service_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_api_service_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2216,7 +2216,7 @@ def _patch_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2255,7 +2255,7 @@ def _patch_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2267,7 +2267,7 @@ def _patch_api_service_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2281,7 +2281,7 @@ def _patch_api_service_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2489,7 +2489,7 @@ def _read_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ def _read_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2727,7 +2727,7 @@ def _read_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2748,7 +2748,7 @@ def _read_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3003,7 +3003,7 @@ def _replace_api_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3038,7 +3038,7 @@ def _replace_api_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3293,7 +3293,7 @@ def _replace_api_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3328,7 +3328,7 @@ def _replace_api_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apis_api.py b/kubernetes/client/api/apis_api.py index d9e2225a90..88a4ea6d8c 100644 --- a/kubernetes/client/api/apis_api.py +++ b/kubernetes/client/api/apis_api.py @@ -220,7 +220,7 @@ def _get_api_versions_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_versions_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apps_api.py b/kubernetes/client/api/apps_api.py index 8f22514a05..d9b78cec6d 100644 --- a/kubernetes/client/api/apps_api.py +++ b/kubernetes/client/api/apps_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/apps_v1_api.py b/kubernetes/client/api/apps_v1_api.py index e743e24006..8e6b874684 100644 --- a/kubernetes/client/api/apps_v1_api.py +++ b/kubernetes/client/api/apps_v1_api.py @@ -294,7 +294,7 @@ def _create_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -329,7 +329,7 @@ def _create_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -586,7 +586,7 @@ def _create_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -621,7 +621,7 @@ def _create_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -878,7 +878,7 @@ def _create_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -913,7 +913,7 @@ def _create_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1170,7 +1170,7 @@ def _create_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1205,7 +1205,7 @@ def _create_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1462,7 +1462,7 @@ def _create_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1497,7 +1497,7 @@ def _create_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1849,7 +1849,7 @@ def _delete_collection_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1928,7 +1928,7 @@ def _delete_collection_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2280,7 +2280,7 @@ def _delete_collection_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2359,7 +2359,7 @@ def _delete_collection_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2711,7 +2711,7 @@ def _delete_collection_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2790,7 +2790,7 @@ def _delete_collection_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3142,7 +3142,7 @@ def _delete_collection_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3221,7 +3221,7 @@ def _delete_collection_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3573,7 +3573,7 @@ def _delete_collection_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3652,7 +3652,7 @@ def _delete_collection_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3934,7 +3934,7 @@ def _delete_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3979,7 +3979,7 @@ def _delete_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4261,7 +4261,7 @@ def _delete_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4306,7 +4306,7 @@ def _delete_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4588,7 +4588,7 @@ def _delete_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4633,7 +4633,7 @@ def _delete_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4915,7 +4915,7 @@ def _delete_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4960,7 +4960,7 @@ def _delete_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5242,7 +5242,7 @@ def _delete_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5287,7 +5287,7 @@ def _delete_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5486,7 +5486,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5501,7 +5501,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5808,7 +5808,7 @@ def _list_controller_revision_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5871,7 +5871,7 @@ def _list_controller_revision_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6181,7 +6181,7 @@ def _list_daemon_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6244,7 +6244,7 @@ def _list_daemon_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6554,7 +6554,7 @@ def _list_deployment_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6617,7 +6617,7 @@ def _list_deployment_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6936,7 +6936,7 @@ def _list_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7001,7 +7001,7 @@ def _list_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7320,7 +7320,7 @@ def _list_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7385,7 +7385,7 @@ def _list_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7704,7 +7704,7 @@ def _list_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7769,7 +7769,7 @@ def _list_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8088,7 +8088,7 @@ def _list_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8153,7 +8153,7 @@ def _list_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8472,7 +8472,7 @@ def _list_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8537,7 +8537,7 @@ def _list_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8847,7 +8847,7 @@ def _list_replica_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8910,7 +8910,7 @@ def _list_replica_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9220,7 +9220,7 @@ def _list_stateful_set_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9283,7 +9283,7 @@ def _list_stateful_set_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9559,7 +9559,7 @@ def _patch_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9600,7 +9600,7 @@ def _patch_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9612,7 +9612,7 @@ def _patch_namespaced_controller_revision_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9626,7 +9626,7 @@ def _patch_namespaced_controller_revision_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9890,7 +9890,7 @@ def _patch_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9931,7 +9931,7 @@ def _patch_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9943,7 +9943,7 @@ def _patch_namespaced_daemon_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9957,7 +9957,7 @@ def _patch_namespaced_daemon_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10221,7 +10221,7 @@ def _patch_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10262,7 +10262,7 @@ def _patch_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10274,7 +10274,7 @@ def _patch_namespaced_daemon_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10288,7 +10288,7 @@ def _patch_namespaced_daemon_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10552,7 +10552,7 @@ def _patch_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10593,7 +10593,7 @@ def _patch_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10605,7 +10605,7 @@ def _patch_namespaced_deployment_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10619,7 +10619,7 @@ def _patch_namespaced_deployment_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10883,7 +10883,7 @@ def _patch_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10924,7 +10924,7 @@ def _patch_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10936,7 +10936,7 @@ def _patch_namespaced_deployment_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10950,7 +10950,7 @@ def _patch_namespaced_deployment_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11214,7 +11214,7 @@ def _patch_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11255,7 +11255,7 @@ def _patch_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11267,7 +11267,7 @@ def _patch_namespaced_deployment_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11281,7 +11281,7 @@ def _patch_namespaced_deployment_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11545,7 +11545,7 @@ def _patch_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11586,7 +11586,7 @@ def _patch_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11598,7 +11598,7 @@ def _patch_namespaced_replica_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11612,7 +11612,7 @@ def _patch_namespaced_replica_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11876,7 +11876,7 @@ def _patch_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11917,7 +11917,7 @@ def _patch_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11929,7 +11929,7 @@ def _patch_namespaced_replica_set_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11943,7 +11943,7 @@ def _patch_namespaced_replica_set_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12207,7 +12207,7 @@ def _patch_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12248,7 +12248,7 @@ def _patch_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12260,7 +12260,7 @@ def _patch_namespaced_replica_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12274,7 +12274,7 @@ def _patch_namespaced_replica_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12538,7 +12538,7 @@ def _patch_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12579,7 +12579,7 @@ def _patch_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12591,7 +12591,7 @@ def _patch_namespaced_stateful_set_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12605,7 +12605,7 @@ def _patch_namespaced_stateful_set_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -12869,7 +12869,7 @@ def _patch_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12910,7 +12910,7 @@ def _patch_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12922,7 +12922,7 @@ def _patch_namespaced_stateful_set_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -12936,7 +12936,7 @@ def _patch_namespaced_stateful_set_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13200,7 +13200,7 @@ def _patch_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13241,7 +13241,7 @@ def _patch_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13253,7 +13253,7 @@ def _patch_namespaced_stateful_set_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -13267,7 +13267,7 @@ def _patch_namespaced_stateful_set_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -13484,7 +13484,7 @@ def _read_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13507,7 +13507,7 @@ def _read_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13733,7 +13733,7 @@ def _read_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13756,7 +13756,7 @@ def _read_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13982,7 +13982,7 @@ def _read_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14005,7 +14005,7 @@ def _read_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14231,7 +14231,7 @@ def _read_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14254,7 +14254,7 @@ def _read_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14480,7 +14480,7 @@ def _read_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14503,7 +14503,7 @@ def _read_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14729,7 +14729,7 @@ def _read_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14752,7 +14752,7 @@ def _read_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14978,7 +14978,7 @@ def _read_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15001,7 +15001,7 @@ def _read_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15227,7 +15227,7 @@ def _read_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15250,7 +15250,7 @@ def _read_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15476,7 +15476,7 @@ def _read_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15499,7 +15499,7 @@ def _read_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15725,7 +15725,7 @@ def _read_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15748,7 +15748,7 @@ def _read_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15974,7 +15974,7 @@ def _read_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15997,7 +15997,7 @@ def _read_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16223,7 +16223,7 @@ def _read_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16246,7 +16246,7 @@ def _read_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16510,7 +16510,7 @@ def _replace_namespaced_controller_revision_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16547,7 +16547,7 @@ def _replace_namespaced_controller_revision_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16811,7 +16811,7 @@ def _replace_namespaced_daemon_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16848,7 +16848,7 @@ def _replace_namespaced_daemon_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17112,7 +17112,7 @@ def _replace_namespaced_daemon_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17149,7 +17149,7 @@ def _replace_namespaced_daemon_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17413,7 +17413,7 @@ def _replace_namespaced_deployment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17450,7 +17450,7 @@ def _replace_namespaced_deployment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17714,7 +17714,7 @@ def _replace_namespaced_deployment_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17751,7 +17751,7 @@ def _replace_namespaced_deployment_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18015,7 +18015,7 @@ def _replace_namespaced_deployment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18052,7 +18052,7 @@ def _replace_namespaced_deployment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18316,7 +18316,7 @@ def _replace_namespaced_replica_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18353,7 +18353,7 @@ def _replace_namespaced_replica_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18617,7 +18617,7 @@ def _replace_namespaced_replica_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18654,7 +18654,7 @@ def _replace_namespaced_replica_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18918,7 +18918,7 @@ def _replace_namespaced_replica_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18955,7 +18955,7 @@ def _replace_namespaced_replica_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19219,7 +19219,7 @@ def _replace_namespaced_stateful_set_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19256,7 +19256,7 @@ def _replace_namespaced_stateful_set_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19520,7 +19520,7 @@ def _replace_namespaced_stateful_set_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19557,7 +19557,7 @@ def _replace_namespaced_stateful_set_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19821,7 +19821,7 @@ def _replace_namespaced_stateful_set_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19858,7 +19858,7 @@ def _replace_namespaced_stateful_set_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/authentication_api.py b/kubernetes/client/api/authentication_api.py index 85c419d77a..3861d4faeb 100644 --- a/kubernetes/client/api/authentication_api.py +++ b/kubernetes/client/api/authentication_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/authentication_v1_api.py b/kubernetes/client/api/authentication_v1_api.py index 804751da14..d69224cbef 100644 --- a/kubernetes/client/api/authentication_v1_api.py +++ b/kubernetes/client/api/authentication_v1_api.py @@ -274,7 +274,7 @@ def _create_self_subject_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -307,7 +307,7 @@ def _create_self_subject_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -555,7 +555,7 @@ def _create_token_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -588,7 +588,7 @@ def _create_token_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -787,7 +787,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -802,7 +802,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/authorization_api.py b/kubernetes/client/api/authorization_api.py index adc1bf9c83..b94167fec7 100644 --- a/kubernetes/client/api/authorization_api.py +++ b/kubernetes/client/api/authorization_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/authorization_v1_api.py b/kubernetes/client/api/authorization_v1_api.py index c4a2fdf93c..ea12b8b05b 100644 --- a/kubernetes/client/api/authorization_v1_api.py +++ b/kubernetes/client/api/authorization_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_local_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_local_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -568,7 +568,7 @@ def _create_self_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -601,7 +601,7 @@ def _create_self_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -849,7 +849,7 @@ def _create_self_subject_rules_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -882,7 +882,7 @@ def _create_self_subject_rules_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1130,7 +1130,7 @@ def _create_subject_access_review_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1163,7 +1163,7 @@ def _create_subject_access_review_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1362,7 +1362,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1377,7 +1377,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/autoscaling_api.py b/kubernetes/client/api/autoscaling_api.py index 529db3c459..b6e412fd49 100644 --- a/kubernetes/client/api/autoscaling_api.py +++ b/kubernetes/client/api/autoscaling_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/autoscaling_v1_api.py b/kubernetes/client/api/autoscaling_v1_api.py index a87c73b120..49c4fde3c0 100644 --- a/kubernetes/client/api/autoscaling_v1_api.py +++ b/kubernetes/client/api/autoscaling_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2653,7 +2653,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2694,7 +2694,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2706,7 +2706,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2720,7 +2720,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2937,7 +2937,7 @@ def _read_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2960,7 +2960,7 @@ def _read_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3186,7 +3186,7 @@ def _read_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3209,7 +3209,7 @@ def _read_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3473,7 +3473,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3510,7 +3510,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3774,7 +3774,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3811,7 +3811,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/autoscaling_v2_api.py b/kubernetes/client/api/autoscaling_v2_api.py index 3167131a58..b3f8846777 100644 --- a/kubernetes/client/api/autoscaling_v2_api.py +++ b/kubernetes/client/api/autoscaling_v2_api.py @@ -285,7 +285,7 @@ def _create_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_horizontal_pod_autoscaler_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2653,7 +2653,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2694,7 +2694,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2706,7 +2706,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2720,7 +2720,7 @@ def _patch_namespaced_horizontal_pod_autoscaler_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2937,7 +2937,7 @@ def _read_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2960,7 +2960,7 @@ def _read_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3186,7 +3186,7 @@ def _read_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3209,7 +3209,7 @@ def _read_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3473,7 +3473,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3510,7 +3510,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3774,7 +3774,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3811,7 +3811,7 @@ def _replace_namespaced_horizontal_pod_autoscaler_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/batch_api.py b/kubernetes/client/api/batch_api.py index eddf52b636..76e6e52bef 100644 --- a/kubernetes/client/api/batch_api.py +++ b/kubernetes/client/api/batch_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/batch_v1_api.py b/kubernetes/client/api/batch_v1_api.py index 08e447a070..2902b229c0 100644 --- a/kubernetes/client/api/batch_v1_api.py +++ b/kubernetes/client/api/batch_v1_api.py @@ -287,7 +287,7 @@ def _create_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -322,7 +322,7 @@ def _create_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -579,7 +579,7 @@ def _create_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -614,7 +614,7 @@ def _create_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -966,7 +966,7 @@ def _delete_collection_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_collection_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1397,7 +1397,7 @@ def _delete_collection_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1476,7 +1476,7 @@ def _delete_collection_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1758,7 +1758,7 @@ def _delete_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1803,7 +1803,7 @@ def _delete_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2085,7 +2085,7 @@ def _delete_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2130,7 +2130,7 @@ def _delete_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2329,7 +2329,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2344,7 +2344,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2651,7 +2651,7 @@ def _list_cron_job_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2714,7 +2714,7 @@ def _list_cron_job_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3024,7 +3024,7 @@ def _list_job_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3087,7 +3087,7 @@ def _list_job_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3406,7 +3406,7 @@ def _list_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3471,7 +3471,7 @@ def _list_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3790,7 +3790,7 @@ def _list_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3855,7 +3855,7 @@ def _list_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4131,7 +4131,7 @@ def _patch_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4172,7 +4172,7 @@ def _patch_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4184,7 +4184,7 @@ def _patch_namespaced_cron_job_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4198,7 +4198,7 @@ def _patch_namespaced_cron_job_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4462,7 +4462,7 @@ def _patch_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4503,7 +4503,7 @@ def _patch_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4515,7 +4515,7 @@ def _patch_namespaced_cron_job_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4529,7 +4529,7 @@ def _patch_namespaced_cron_job_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4793,7 +4793,7 @@ def _patch_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4834,7 +4834,7 @@ def _patch_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4846,7 +4846,7 @@ def _patch_namespaced_job_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4860,7 +4860,7 @@ def _patch_namespaced_job_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5124,7 +5124,7 @@ def _patch_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5165,7 +5165,7 @@ def _patch_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5177,7 +5177,7 @@ def _patch_namespaced_job_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5191,7 +5191,7 @@ def _patch_namespaced_job_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5408,7 +5408,7 @@ def _read_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5431,7 +5431,7 @@ def _read_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5657,7 +5657,7 @@ def _read_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5680,7 +5680,7 @@ def _read_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5906,7 +5906,7 @@ def _read_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5929,7 +5929,7 @@ def _read_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6155,7 +6155,7 @@ def _read_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6178,7 +6178,7 @@ def _read_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6442,7 +6442,7 @@ def _replace_namespaced_cron_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6479,7 +6479,7 @@ def _replace_namespaced_cron_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6743,7 +6743,7 @@ def _replace_namespaced_cron_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6780,7 +6780,7 @@ def _replace_namespaced_cron_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7044,7 +7044,7 @@ def _replace_namespaced_job_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7081,7 +7081,7 @@ def _replace_namespaced_job_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7345,7 +7345,7 @@ def _replace_namespaced_job_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7382,7 +7382,7 @@ def _replace_namespaced_job_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/certificates_api.py b/kubernetes/client/api/certificates_api.py index 1c34337ae3..6066ff98f2 100644 --- a/kubernetes/client/api/certificates_api.py +++ b/kubernetes/client/api/certificates_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/certificates_v1_api.py b/kubernetes/client/api/certificates_v1_api.py index b8c9afef23..5739529ad7 100644 --- a/kubernetes/client/api/certificates_v1_api.py +++ b/kubernetes/client/api/certificates_v1_api.py @@ -280,7 +280,7 @@ def _create_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -313,7 +313,7 @@ def _create_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -561,7 +561,7 @@ def _create_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -594,7 +594,7 @@ def _create_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -851,7 +851,7 @@ def _create_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -886,7 +886,7 @@ def _create_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1159,7 +1159,7 @@ def _delete_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1202,7 +1202,7 @@ def _delete_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1475,7 +1475,7 @@ def _delete_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1518,7 +1518,7 @@ def _delete_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1861,7 +1861,7 @@ def _delete_collection_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1938,7 +1938,7 @@ def _delete_collection_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2281,7 +2281,7 @@ def _delete_collection_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2358,7 +2358,7 @@ def _delete_collection_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2710,7 +2710,7 @@ def _delete_collection_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2789,7 +2789,7 @@ def _delete_collection_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3071,7 +3071,7 @@ def _delete_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3116,7 +3116,7 @@ def _delete_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3315,7 +3315,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3330,7 +3330,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3637,7 +3637,7 @@ def _list_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3700,7 +3700,7 @@ def _list_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4010,7 +4010,7 @@ def _list_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4073,7 +4073,7 @@ def _list_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4392,7 +4392,7 @@ def _list_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4457,7 +4457,7 @@ def _list_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4767,7 +4767,7 @@ def _list_pod_certificate_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4830,7 +4830,7 @@ def _list_pod_certificate_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5097,7 +5097,7 @@ def _patch_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5136,7 +5136,7 @@ def _patch_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5148,7 +5148,7 @@ def _patch_certificate_signing_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5162,7 +5162,7 @@ def _patch_certificate_signing_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5417,7 +5417,7 @@ def _patch_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5456,7 +5456,7 @@ def _patch_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5468,7 +5468,7 @@ def _patch_certificate_signing_request_approval_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5482,7 +5482,7 @@ def _patch_certificate_signing_request_approval_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5737,7 +5737,7 @@ def _patch_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5776,7 +5776,7 @@ def _patch_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5788,7 +5788,7 @@ def _patch_certificate_signing_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5802,7 +5802,7 @@ def _patch_certificate_signing_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6057,7 +6057,7 @@ def _patch_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6096,7 +6096,7 @@ def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6108,7 +6108,7 @@ def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6122,7 +6122,7 @@ def _patch_cluster_trust_bundle_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6386,7 +6386,7 @@ def _patch_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6427,7 +6427,7 @@ def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6439,7 +6439,7 @@ def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6453,7 +6453,7 @@ def _patch_namespaced_pod_certificate_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6717,7 +6717,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6758,7 +6758,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6770,7 +6770,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6784,7 +6784,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6992,7 +6992,7 @@ def _read_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7013,7 +7013,7 @@ def _read_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7230,7 +7230,7 @@ def _read_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7251,7 +7251,7 @@ def _read_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7468,7 +7468,7 @@ def _read_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7489,7 +7489,7 @@ def _read_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7706,7 +7706,7 @@ def _read_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7727,7 +7727,7 @@ def _read_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7953,7 +7953,7 @@ def _read_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7976,7 +7976,7 @@ def _read_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8202,7 +8202,7 @@ def _read_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8225,7 +8225,7 @@ def _read_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8480,7 +8480,7 @@ def _replace_certificate_signing_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8515,7 +8515,7 @@ def _replace_certificate_signing_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8770,7 +8770,7 @@ def _replace_certificate_signing_request_approval_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8805,7 +8805,7 @@ def _replace_certificate_signing_request_approval_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9060,7 +9060,7 @@ def _replace_certificate_signing_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9095,7 +9095,7 @@ def _replace_certificate_signing_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9350,7 +9350,7 @@ def _replace_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9385,7 +9385,7 @@ def _replace_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9649,7 +9649,7 @@ def _replace_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9686,7 +9686,7 @@ def _replace_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9950,7 +9950,7 @@ def _replace_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9987,7 +9987,7 @@ def _replace_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/certificates_v1beta1_api.py b/kubernetes/client/api/certificates_v1beta1_api.py index 8ba9dd4613..e6db5167d8 100644 --- a/kubernetes/client/api/certificates_v1beta1_api.py +++ b/kubernetes/client/api/certificates_v1beta1_api.py @@ -278,7 +278,7 @@ def _create_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _create_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -568,7 +568,7 @@ def _create_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -603,7 +603,7 @@ def _create_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -876,7 +876,7 @@ def _delete_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -919,7 +919,7 @@ def _delete_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1262,7 +1262,7 @@ def _delete_collection_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1339,7 +1339,7 @@ def _delete_collection_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1691,7 +1691,7 @@ def _delete_collection_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1770,7 +1770,7 @@ def _delete_collection_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2052,7 +2052,7 @@ def _delete_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2097,7 +2097,7 @@ def _delete_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2296,7 +2296,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2311,7 +2311,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2618,7 +2618,7 @@ def _list_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2681,7 +2681,7 @@ def _list_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3000,7 +3000,7 @@ def _list_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3065,7 +3065,7 @@ def _list_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3375,7 +3375,7 @@ def _list_pod_certificate_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3438,7 +3438,7 @@ def _list_pod_certificate_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3705,7 +3705,7 @@ def _patch_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3744,7 +3744,7 @@ def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3756,7 +3756,7 @@ def _patch_cluster_trust_bundle_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3770,7 +3770,7 @@ def _patch_cluster_trust_bundle_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4034,7 +4034,7 @@ def _patch_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4075,7 +4075,7 @@ def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4087,7 +4087,7 @@ def _patch_namespaced_pod_certificate_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4101,7 +4101,7 @@ def _patch_namespaced_pod_certificate_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4365,7 +4365,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4406,7 +4406,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4418,7 +4418,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4432,7 +4432,7 @@ def _patch_namespaced_pod_certificate_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4640,7 +4640,7 @@ def _read_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4661,7 +4661,7 @@ def _read_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4887,7 +4887,7 @@ def _read_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4910,7 +4910,7 @@ def _read_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5136,7 +5136,7 @@ def _read_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5159,7 +5159,7 @@ def _read_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5414,7 +5414,7 @@ def _replace_cluster_trust_bundle_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5449,7 +5449,7 @@ def _replace_cluster_trust_bundle_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5713,7 +5713,7 @@ def _replace_namespaced_pod_certificate_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5750,7 +5750,7 @@ def _replace_namespaced_pod_certificate_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6014,7 +6014,7 @@ def _replace_namespaced_pod_certificate_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6051,7 +6051,7 @@ def _replace_namespaced_pod_certificate_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/coordination_api.py b/kubernetes/client/api/coordination_api.py index 5462931610..de66937b5c 100644 --- a/kubernetes/client/api/coordination_api.py +++ b/kubernetes/client/api/coordination_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/coordination_v1_api.py b/kubernetes/client/api/coordination_v1_api.py index a672087375..d7092f7492 100644 --- a/kubernetes/client/api/coordination_v1_api.py +++ b/kubernetes/client/api/coordination_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_lease_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_lease_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_lease_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_lease_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2606,7 +2606,7 @@ def _read_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2629,7 +2629,7 @@ def _read_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2893,7 +2893,7 @@ def _replace_namespaced_lease_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2930,7 +2930,7 @@ def _replace_namespaced_lease_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/coordination_v1alpha2_api.py b/kubernetes/client/api/coordination_v1alpha2_api.py index bdba1e43e9..b2bda69234 100644 --- a/kubernetes/client/api/coordination_v1alpha2_api.py +++ b/kubernetes/client/api/coordination_v1alpha2_api.py @@ -285,7 +285,7 @@ def _create_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_lease_candidate_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_lease_candidate_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_lease_candidate_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2606,7 +2606,7 @@ def _read_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2629,7 +2629,7 @@ def _read_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2893,7 +2893,7 @@ def _replace_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2930,7 +2930,7 @@ def _replace_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/coordination_v1beta1_api.py b/kubernetes/client/api/coordination_v1beta1_api.py index c49642b9ae..b680cc5679 100644 --- a/kubernetes/client/api/coordination_v1beta1_api.py +++ b/kubernetes/client/api/coordination_v1beta1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_lease_candidate_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_lease_candidate_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_lease_candidate_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_lease_candidate_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2606,7 +2606,7 @@ def _read_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2629,7 +2629,7 @@ def _read_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2893,7 +2893,7 @@ def _replace_namespaced_lease_candidate_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2930,7 +2930,7 @@ def _replace_namespaced_lease_candidate_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/core_api.py b/kubernetes/client/api/core_api.py index 0fa6311eb9..bafbb65dfe 100644 --- a/kubernetes/client/api/core_api.py +++ b/kubernetes/client/api/core_api.py @@ -220,7 +220,7 @@ def _get_api_versions_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_versions_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/core_v1_api.py b/kubernetes/client/api/core_v1_api.py index 5336e3033f..b064c8e550 100644 --- a/kubernetes/client/api/core_v1_api.py +++ b/kubernetes/client/api/core_v1_api.py @@ -288,7 +288,7 @@ def _connect_delete_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _connect_delete_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -543,7 +543,7 @@ def _connect_delete_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -568,7 +568,7 @@ def _connect_delete_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -791,7 +791,7 @@ def _connect_delete_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -814,7 +814,7 @@ def _connect_delete_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1046,7 +1046,7 @@ def _connect_delete_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1071,7 +1071,7 @@ def _connect_delete_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1285,7 +1285,7 @@ def _connect_delete_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1306,7 +1306,7 @@ def _connect_delete_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1529,7 +1529,7 @@ def _connect_delete_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1552,7 +1552,7 @@ def _connect_delete_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -1811,7 +1811,7 @@ def _connect_get_namespaced_pod_attach_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1850,7 +1850,7 @@ def _connect_get_namespaced_pod_attach_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2119,7 +2119,7 @@ def _connect_get_namespaced_pod_exec_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2162,7 +2162,7 @@ def _connect_get_namespaced_pod_exec_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2385,7 +2385,7 @@ def _connect_get_namespaced_pod_portforward_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2408,7 +2408,7 @@ def _connect_get_namespaced_pod_portforward_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2631,7 +2631,7 @@ def _connect_get_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2654,7 +2654,7 @@ def _connect_get_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -2886,7 +2886,7 @@ def _connect_get_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2911,7 +2911,7 @@ def _connect_get_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3134,7 +3134,7 @@ def _connect_get_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3157,7 +3157,7 @@ def _connect_get_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3389,7 +3389,7 @@ def _connect_get_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3414,7 +3414,7 @@ def _connect_get_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3628,7 +3628,7 @@ def _connect_get_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3649,7 +3649,7 @@ def _connect_get_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -3872,7 +3872,7 @@ def _connect_get_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3895,7 +3895,7 @@ def _connect_get_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4118,7 +4118,7 @@ def _connect_head_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4141,7 +4141,7 @@ def _connect_head_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4373,7 +4373,7 @@ def _connect_head_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4398,7 +4398,7 @@ def _connect_head_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4621,7 +4621,7 @@ def _connect_head_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4644,7 +4644,7 @@ def _connect_head_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -4876,7 +4876,7 @@ def _connect_head_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4901,7 +4901,7 @@ def _connect_head_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5115,7 +5115,7 @@ def _connect_head_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5136,7 +5136,7 @@ def _connect_head_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5359,7 +5359,7 @@ def _connect_head_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5382,7 +5382,7 @@ def _connect_head_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5605,7 +5605,7 @@ def _connect_options_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5628,7 +5628,7 @@ def _connect_options_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -5860,7 +5860,7 @@ def _connect_options_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5885,7 +5885,7 @@ def _connect_options_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6108,7 +6108,7 @@ def _connect_options_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6131,7 +6131,7 @@ def _connect_options_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6363,7 +6363,7 @@ def _connect_options_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6388,7 +6388,7 @@ def _connect_options_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6602,7 +6602,7 @@ def _connect_options_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6623,7 +6623,7 @@ def _connect_options_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -6846,7 +6846,7 @@ def _connect_options_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6869,7 +6869,7 @@ def _connect_options_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7092,7 +7092,7 @@ def _connect_patch_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7115,7 +7115,7 @@ def _connect_patch_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7347,7 +7347,7 @@ def _connect_patch_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7372,7 +7372,7 @@ def _connect_patch_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7595,7 +7595,7 @@ def _connect_patch_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7618,7 +7618,7 @@ def _connect_patch_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -7850,7 +7850,7 @@ def _connect_patch_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7875,7 +7875,7 @@ def _connect_patch_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8089,7 +8089,7 @@ def _connect_patch_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8110,7 +8110,7 @@ def _connect_patch_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8333,7 +8333,7 @@ def _connect_patch_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8356,7 +8356,7 @@ def _connect_patch_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8615,7 +8615,7 @@ def _connect_post_namespaced_pod_attach_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8654,7 +8654,7 @@ def _connect_post_namespaced_pod_attach_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -8923,7 +8923,7 @@ def _connect_post_namespaced_pod_exec_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8966,7 +8966,7 @@ def _connect_post_namespaced_pod_exec_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9189,7 +9189,7 @@ def _connect_post_namespaced_pod_portforward_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9212,7 +9212,7 @@ def _connect_post_namespaced_pod_portforward_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9435,7 +9435,7 @@ def _connect_post_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9458,7 +9458,7 @@ def _connect_post_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9690,7 +9690,7 @@ def _connect_post_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9715,7 +9715,7 @@ def _connect_post_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -9938,7 +9938,7 @@ def _connect_post_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9961,7 +9961,7 @@ def _connect_post_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10193,7 +10193,7 @@ def _connect_post_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10218,7 +10218,7 @@ def _connect_post_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10432,7 +10432,7 @@ def _connect_post_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10453,7 +10453,7 @@ def _connect_post_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10676,7 +10676,7 @@ def _connect_post_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10699,7 +10699,7 @@ def _connect_post_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -10922,7 +10922,7 @@ def _connect_put_namespaced_pod_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10945,7 +10945,7 @@ def _connect_put_namespaced_pod_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11177,7 +11177,7 @@ def _connect_put_namespaced_pod_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11202,7 +11202,7 @@ def _connect_put_namespaced_pod_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11425,7 +11425,7 @@ def _connect_put_namespaced_service_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11448,7 +11448,7 @@ def _connect_put_namespaced_service_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11680,7 +11680,7 @@ def _connect_put_namespaced_service_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11705,7 +11705,7 @@ def _connect_put_namespaced_service_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -11919,7 +11919,7 @@ def _connect_put_node_proxy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11940,7 +11940,7 @@ def _connect_put_node_proxy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12163,7 +12163,7 @@ def _connect_put_node_proxy_with_path_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12186,7 +12186,7 @@ def _connect_put_node_proxy_with_path_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ '*/*' @@ -12431,7 +12431,7 @@ def _create_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12464,7 +12464,7 @@ def _create_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12721,7 +12721,7 @@ def _create_namespaced_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12756,7 +12756,7 @@ def _create_namespaced_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13013,7 +13013,7 @@ def _create_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13048,7 +13048,7 @@ def _create_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13305,7 +13305,7 @@ def _create_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13340,7 +13340,7 @@ def _create_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13597,7 +13597,7 @@ def _create_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13632,7 +13632,7 @@ def _create_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13889,7 +13889,7 @@ def _create_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13924,7 +13924,7 @@ def _create_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14181,7 +14181,7 @@ def _create_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14216,7 +14216,7 @@ def _create_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14473,7 +14473,7 @@ def _create_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14508,7 +14508,7 @@ def _create_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14774,7 +14774,7 @@ def _create_namespaced_pod_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14811,7 +14811,7 @@ def _create_namespaced_pod_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15077,7 +15077,7 @@ def _create_namespaced_pod_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15114,7 +15114,7 @@ def _create_namespaced_pod_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15371,7 +15371,7 @@ def _create_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15406,7 +15406,7 @@ def _create_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15663,7 +15663,7 @@ def _create_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15698,7 +15698,7 @@ def _create_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15955,7 +15955,7 @@ def _create_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15990,7 +15990,7 @@ def _create_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16247,7 +16247,7 @@ def _create_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16282,7 +16282,7 @@ def _create_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16539,7 +16539,7 @@ def _create_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16574,7 +16574,7 @@ def _create_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -16831,7 +16831,7 @@ def _create_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -16866,7 +16866,7 @@ def _create_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17132,7 +17132,7 @@ def _create_namespaced_service_account_token_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17169,7 +17169,7 @@ def _create_namespaced_service_account_token_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17417,7 +17417,7 @@ def _create_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17450,7 +17450,7 @@ def _create_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -17698,7 +17698,7 @@ def _create_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -17731,7 +17731,7 @@ def _create_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18083,7 +18083,7 @@ def _delete_collection_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18162,7 +18162,7 @@ def _delete_collection_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18514,7 +18514,7 @@ def _delete_collection_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -18593,7 +18593,7 @@ def _delete_collection_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -18945,7 +18945,7 @@ def _delete_collection_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19024,7 +19024,7 @@ def _delete_collection_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19376,7 +19376,7 @@ def _delete_collection_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19455,7 +19455,7 @@ def _delete_collection_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -19807,7 +19807,7 @@ def _delete_collection_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -19886,7 +19886,7 @@ def _delete_collection_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20238,7 +20238,7 @@ def _delete_collection_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20317,7 +20317,7 @@ def _delete_collection_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -20669,7 +20669,7 @@ def _delete_collection_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -20748,7 +20748,7 @@ def _delete_collection_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21100,7 +21100,7 @@ def _delete_collection_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21179,7 +21179,7 @@ def _delete_collection_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21531,7 +21531,7 @@ def _delete_collection_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -21610,7 +21610,7 @@ def _delete_collection_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -21962,7 +21962,7 @@ def _delete_collection_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22041,7 +22041,7 @@ def _delete_collection_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22393,7 +22393,7 @@ def _delete_collection_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22472,7 +22472,7 @@ def _delete_collection_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -22824,7 +22824,7 @@ def _delete_collection_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -22903,7 +22903,7 @@ def _delete_collection_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23246,7 +23246,7 @@ def _delete_collection_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23323,7 +23323,7 @@ def _delete_collection_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -23666,7 +23666,7 @@ def _delete_collection_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -23743,7 +23743,7 @@ def _delete_collection_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24016,7 +24016,7 @@ def _delete_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24059,7 +24059,7 @@ def _delete_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24341,7 +24341,7 @@ def _delete_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24386,7 +24386,7 @@ def _delete_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24668,7 +24668,7 @@ def _delete_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -24713,7 +24713,7 @@ def _delete_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -24995,7 +24995,7 @@ def _delete_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -25040,7 +25040,7 @@ def _delete_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -25322,7 +25322,7 @@ def _delete_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -25367,7 +25367,7 @@ def _delete_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -25649,7 +25649,7 @@ def _delete_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -25694,7 +25694,7 @@ def _delete_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -25976,7 +25976,7 @@ def _delete_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -26021,7 +26021,7 @@ def _delete_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -26303,7 +26303,7 @@ def _delete_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -26348,7 +26348,7 @@ def _delete_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -26630,7 +26630,7 @@ def _delete_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -26675,7 +26675,7 @@ def _delete_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -26957,7 +26957,7 @@ def _delete_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27002,7 +27002,7 @@ def _delete_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -27284,7 +27284,7 @@ def _delete_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27329,7 +27329,7 @@ def _delete_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -27611,7 +27611,7 @@ def _delete_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27656,7 +27656,7 @@ def _delete_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -27938,7 +27938,7 @@ def _delete_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -27983,7 +27983,7 @@ def _delete_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -28256,7 +28256,7 @@ def _delete_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -28299,7 +28299,7 @@ def _delete_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -28572,7 +28572,7 @@ def _delete_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -28615,7 +28615,7 @@ def _delete_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -28814,7 +28814,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -28829,7 +28829,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -29136,7 +29136,7 @@ def _list_component_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29199,7 +29199,7 @@ def _list_component_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -29509,7 +29509,7 @@ def _list_config_map_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29572,7 +29572,7 @@ def _list_config_map_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -29882,7 +29882,7 @@ def _list_endpoints_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -29945,7 +29945,7 @@ def _list_endpoints_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -30255,7 +30255,7 @@ def _list_event_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -30318,7 +30318,7 @@ def _list_event_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -30628,7 +30628,7 @@ def _list_limit_range_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -30691,7 +30691,7 @@ def _list_limit_range_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -31001,7 +31001,7 @@ def _list_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31064,7 +31064,7 @@ def _list_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -31383,7 +31383,7 @@ def _list_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31448,7 +31448,7 @@ def _list_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -31767,7 +31767,7 @@ def _list_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -31832,7 +31832,7 @@ def _list_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32151,7 +32151,7 @@ def _list_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -32216,7 +32216,7 @@ def _list_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32535,7 +32535,7 @@ def _list_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -32600,7 +32600,7 @@ def _list_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -32919,7 +32919,7 @@ def _list_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -32984,7 +32984,7 @@ def _list_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -33303,7 +33303,7 @@ def _list_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -33368,7 +33368,7 @@ def _list_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -33687,7 +33687,7 @@ def _list_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -33752,7 +33752,7 @@ def _list_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34071,7 +34071,7 @@ def _list_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -34136,7 +34136,7 @@ def _list_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34455,7 +34455,7 @@ def _list_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -34520,7 +34520,7 @@ def _list_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -34839,7 +34839,7 @@ def _list_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -34904,7 +34904,7 @@ def _list_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -35223,7 +35223,7 @@ def _list_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -35288,7 +35288,7 @@ def _list_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -35607,7 +35607,7 @@ def _list_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -35672,7 +35672,7 @@ def _list_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -35982,7 +35982,7 @@ def _list_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -36045,7 +36045,7 @@ def _list_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -36355,7 +36355,7 @@ def _list_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -36418,7 +36418,7 @@ def _list_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -36728,7 +36728,7 @@ def _list_persistent_volume_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -36791,7 +36791,7 @@ def _list_persistent_volume_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37101,7 +37101,7 @@ def _list_pod_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -37164,7 +37164,7 @@ def _list_pod_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37474,7 +37474,7 @@ def _list_pod_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -37537,7 +37537,7 @@ def _list_pod_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -37847,7 +37847,7 @@ def _list_replication_controller_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -37910,7 +37910,7 @@ def _list_replication_controller_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -38220,7 +38220,7 @@ def _list_resource_quota_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -38283,7 +38283,7 @@ def _list_resource_quota_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -38593,7 +38593,7 @@ def _list_secret_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -38656,7 +38656,7 @@ def _list_secret_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -38966,7 +38966,7 @@ def _list_service_account_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -39029,7 +39029,7 @@ def _list_service_account_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -39339,7 +39339,7 @@ def _list_service_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -39402,7 +39402,7 @@ def _list_service_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -39669,7 +39669,7 @@ def _patch_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -39708,7 +39708,7 @@ def _patch_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -39720,7 +39720,7 @@ def _patch_namespace_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -39734,7 +39734,7 @@ def _patch_namespace_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -39989,7 +39989,7 @@ def _patch_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -40028,7 +40028,7 @@ def _patch_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -40040,7 +40040,7 @@ def _patch_namespace_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -40054,7 +40054,7 @@ def _patch_namespace_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -40318,7 +40318,7 @@ def _patch_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -40359,7 +40359,7 @@ def _patch_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -40371,7 +40371,7 @@ def _patch_namespaced_config_map_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -40385,7 +40385,7 @@ def _patch_namespaced_config_map_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -40649,7 +40649,7 @@ def _patch_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -40690,7 +40690,7 @@ def _patch_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -40702,7 +40702,7 @@ def _patch_namespaced_endpoints_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -40716,7 +40716,7 @@ def _patch_namespaced_endpoints_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -40980,7 +40980,7 @@ def _patch_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -41021,7 +41021,7 @@ def _patch_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -41033,7 +41033,7 @@ def _patch_namespaced_event_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -41047,7 +41047,7 @@ def _patch_namespaced_event_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -41311,7 +41311,7 @@ def _patch_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -41352,7 +41352,7 @@ def _patch_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -41364,7 +41364,7 @@ def _patch_namespaced_limit_range_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -41378,7 +41378,7 @@ def _patch_namespaced_limit_range_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -41642,7 +41642,7 @@ def _patch_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -41683,7 +41683,7 @@ def _patch_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -41695,7 +41695,7 @@ def _patch_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -41709,7 +41709,7 @@ def _patch_namespaced_persistent_volume_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -41973,7 +41973,7 @@ def _patch_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -42014,7 +42014,7 @@ def _patch_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -42026,7 +42026,7 @@ def _patch_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -42040,7 +42040,7 @@ def _patch_namespaced_persistent_volume_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -42304,7 +42304,7 @@ def _patch_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -42345,7 +42345,7 @@ def _patch_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -42357,7 +42357,7 @@ def _patch_namespaced_pod_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -42371,7 +42371,7 @@ def _patch_namespaced_pod_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -42635,7 +42635,7 @@ def _patch_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -42676,7 +42676,7 @@ def _patch_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -42688,7 +42688,7 @@ def _patch_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -42702,7 +42702,7 @@ def _patch_namespaced_pod_ephemeralcontainers_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -42966,7 +42966,7 @@ def _patch_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -43007,7 +43007,7 @@ def _patch_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -43019,7 +43019,7 @@ def _patch_namespaced_pod_resize_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -43033,7 +43033,7 @@ def _patch_namespaced_pod_resize_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -43297,7 +43297,7 @@ def _patch_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -43338,7 +43338,7 @@ def _patch_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -43350,7 +43350,7 @@ def _patch_namespaced_pod_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -43364,7 +43364,7 @@ def _patch_namespaced_pod_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -43628,7 +43628,7 @@ def _patch_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -43669,7 +43669,7 @@ def _patch_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -43681,7 +43681,7 @@ def _patch_namespaced_pod_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -43695,7 +43695,7 @@ def _patch_namespaced_pod_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -43959,7 +43959,7 @@ def _patch_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44000,7 +44000,7 @@ def _patch_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -44012,7 +44012,7 @@ def _patch_namespaced_replication_controller_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -44026,7 +44026,7 @@ def _patch_namespaced_replication_controller_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -44290,7 +44290,7 @@ def _patch_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44331,7 +44331,7 @@ def _patch_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -44343,7 +44343,7 @@ def _patch_namespaced_replication_controller_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -44357,7 +44357,7 @@ def _patch_namespaced_replication_controller_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -44621,7 +44621,7 @@ def _patch_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44662,7 +44662,7 @@ def _patch_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -44674,7 +44674,7 @@ def _patch_namespaced_replication_controller_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -44688,7 +44688,7 @@ def _patch_namespaced_replication_controller_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -44952,7 +44952,7 @@ def _patch_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -44993,7 +44993,7 @@ def _patch_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45005,7 +45005,7 @@ def _patch_namespaced_resource_quota_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -45019,7 +45019,7 @@ def _patch_namespaced_resource_quota_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -45283,7 +45283,7 @@ def _patch_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -45324,7 +45324,7 @@ def _patch_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45336,7 +45336,7 @@ def _patch_namespaced_resource_quota_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -45350,7 +45350,7 @@ def _patch_namespaced_resource_quota_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -45614,7 +45614,7 @@ def _patch_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -45655,7 +45655,7 @@ def _patch_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45667,7 +45667,7 @@ def _patch_namespaced_secret_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -45681,7 +45681,7 @@ def _patch_namespaced_secret_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -45945,7 +45945,7 @@ def _patch_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -45986,7 +45986,7 @@ def _patch_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -45998,7 +45998,7 @@ def _patch_namespaced_service_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -46012,7 +46012,7 @@ def _patch_namespaced_service_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -46276,7 +46276,7 @@ def _patch_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46317,7 +46317,7 @@ def _patch_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -46329,7 +46329,7 @@ def _patch_namespaced_service_account_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -46343,7 +46343,7 @@ def _patch_namespaced_service_account_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -46607,7 +46607,7 @@ def _patch_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46648,7 +46648,7 @@ def _patch_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -46660,7 +46660,7 @@ def _patch_namespaced_service_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -46674,7 +46674,7 @@ def _patch_namespaced_service_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -46929,7 +46929,7 @@ def _patch_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -46968,7 +46968,7 @@ def _patch_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -46980,7 +46980,7 @@ def _patch_node_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -46994,7 +46994,7 @@ def _patch_node_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -47249,7 +47249,7 @@ def _patch_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -47288,7 +47288,7 @@ def _patch_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -47300,7 +47300,7 @@ def _patch_node_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -47314,7 +47314,7 @@ def _patch_node_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -47569,7 +47569,7 @@ def _patch_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -47608,7 +47608,7 @@ def _patch_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -47620,7 +47620,7 @@ def _patch_persistent_volume_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -47634,7 +47634,7 @@ def _patch_persistent_volume_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -47889,7 +47889,7 @@ def _patch_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -47928,7 +47928,7 @@ def _patch_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -47940,7 +47940,7 @@ def _patch_persistent_volume_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -47954,7 +47954,7 @@ def _patch_persistent_volume_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -48162,7 +48162,7 @@ def _read_component_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48183,7 +48183,7 @@ def _read_component_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48400,7 +48400,7 @@ def _read_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48421,7 +48421,7 @@ def _read_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48638,7 +48638,7 @@ def _read_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48659,7 +48659,7 @@ def _read_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -48885,7 +48885,7 @@ def _read_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -48908,7 +48908,7 @@ def _read_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49134,7 +49134,7 @@ def _read_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49157,7 +49157,7 @@ def _read_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49383,7 +49383,7 @@ def _read_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49406,7 +49406,7 @@ def _read_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49632,7 +49632,7 @@ def _read_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49655,7 +49655,7 @@ def _read_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -49881,7 +49881,7 @@ def _read_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -49904,7 +49904,7 @@ def _read_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50130,7 +50130,7 @@ def _read_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -50153,7 +50153,7 @@ def _read_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50379,7 +50379,7 @@ def _read_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -50402,7 +50402,7 @@ def _read_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50628,7 +50628,7 @@ def _read_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -50651,7 +50651,7 @@ def _read_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -50958,7 +50958,7 @@ def _read_namespaced_pod_log_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51017,7 +51017,7 @@ def _read_namespaced_pod_log_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'text/plain', @@ -51244,7 +51244,7 @@ def _read_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51267,7 +51267,7 @@ def _read_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51493,7 +51493,7 @@ def _read_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51516,7 +51516,7 @@ def _read_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51742,7 +51742,7 @@ def _read_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -51765,7 +51765,7 @@ def _read_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -51991,7 +51991,7 @@ def _read_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52014,7 +52014,7 @@ def _read_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52240,7 +52240,7 @@ def _read_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52263,7 +52263,7 @@ def _read_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52489,7 +52489,7 @@ def _read_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52512,7 +52512,7 @@ def _read_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52738,7 +52738,7 @@ def _read_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -52761,7 +52761,7 @@ def _read_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -52987,7 +52987,7 @@ def _read_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53010,7 +53010,7 @@ def _read_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53236,7 +53236,7 @@ def _read_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53259,7 +53259,7 @@ def _read_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53485,7 +53485,7 @@ def _read_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53508,7 +53508,7 @@ def _read_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53734,7 +53734,7 @@ def _read_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -53757,7 +53757,7 @@ def _read_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -53983,7 +53983,7 @@ def _read_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54006,7 +54006,7 @@ def _read_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54223,7 +54223,7 @@ def _read_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54244,7 +54244,7 @@ def _read_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54461,7 +54461,7 @@ def _read_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54482,7 +54482,7 @@ def _read_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54699,7 +54699,7 @@ def _read_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54720,7 +54720,7 @@ def _read_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -54937,7 +54937,7 @@ def _read_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -54958,7 +54958,7 @@ def _read_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55213,7 +55213,7 @@ def _replace_namespace_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55248,7 +55248,7 @@ def _replace_namespace_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55503,7 +55503,7 @@ def _replace_namespace_finalize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55538,7 +55538,7 @@ def _replace_namespace_finalize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -55793,7 +55793,7 @@ def _replace_namespace_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -55828,7 +55828,7 @@ def _replace_namespace_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56092,7 +56092,7 @@ def _replace_namespaced_config_map_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -56129,7 +56129,7 @@ def _replace_namespaced_config_map_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56393,7 +56393,7 @@ def _replace_namespaced_endpoints_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -56430,7 +56430,7 @@ def _replace_namespaced_endpoints_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56694,7 +56694,7 @@ def _replace_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -56731,7 +56731,7 @@ def _replace_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -56995,7 +56995,7 @@ def _replace_namespaced_limit_range_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57032,7 +57032,7 @@ def _replace_namespaced_limit_range_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57296,7 +57296,7 @@ def _replace_namespaced_persistent_volume_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57333,7 +57333,7 @@ def _replace_namespaced_persistent_volume_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57597,7 +57597,7 @@ def _replace_namespaced_persistent_volume_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57634,7 +57634,7 @@ def _replace_namespaced_persistent_volume_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -57898,7 +57898,7 @@ def _replace_namespaced_pod_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -57935,7 +57935,7 @@ def _replace_namespaced_pod_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -58199,7 +58199,7 @@ def _replace_namespaced_pod_ephemeralcontainers_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -58236,7 +58236,7 @@ def _replace_namespaced_pod_ephemeralcontainers_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -58500,7 +58500,7 @@ def _replace_namespaced_pod_resize_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -58537,7 +58537,7 @@ def _replace_namespaced_pod_resize_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -58801,7 +58801,7 @@ def _replace_namespaced_pod_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -58838,7 +58838,7 @@ def _replace_namespaced_pod_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59102,7 +59102,7 @@ def _replace_namespaced_pod_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59139,7 +59139,7 @@ def _replace_namespaced_pod_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59403,7 +59403,7 @@ def _replace_namespaced_replication_controller_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59440,7 +59440,7 @@ def _replace_namespaced_replication_controller_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -59704,7 +59704,7 @@ def _replace_namespaced_replication_controller_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -59741,7 +59741,7 @@ def _replace_namespaced_replication_controller_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60005,7 +60005,7 @@ def _replace_namespaced_replication_controller_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60042,7 +60042,7 @@ def _replace_namespaced_replication_controller_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60306,7 +60306,7 @@ def _replace_namespaced_resource_quota_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60343,7 +60343,7 @@ def _replace_namespaced_resource_quota_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60607,7 +60607,7 @@ def _replace_namespaced_resource_quota_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60644,7 +60644,7 @@ def _replace_namespaced_resource_quota_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -60908,7 +60908,7 @@ def _replace_namespaced_secret_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -60945,7 +60945,7 @@ def _replace_namespaced_secret_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61209,7 +61209,7 @@ def _replace_namespaced_service_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61246,7 +61246,7 @@ def _replace_namespaced_service_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61510,7 +61510,7 @@ def _replace_namespaced_service_account_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61547,7 +61547,7 @@ def _replace_namespaced_service_account_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -61811,7 +61811,7 @@ def _replace_namespaced_service_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -61848,7 +61848,7 @@ def _replace_namespaced_service_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -62103,7 +62103,7 @@ def _replace_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -62138,7 +62138,7 @@ def _replace_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -62393,7 +62393,7 @@ def _replace_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -62428,7 +62428,7 @@ def _replace_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -62683,7 +62683,7 @@ def _replace_persistent_volume_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -62718,7 +62718,7 @@ def _replace_persistent_volume_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -62973,7 +62973,7 @@ def _replace_persistent_volume_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -63008,7 +63008,7 @@ def _replace_persistent_volume_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/custom_objects_api.py b/kubernetes/client/api/custom_objects_api.py index fff568ba8b..99a61efb8e 100644 --- a/kubernetes/client/api/custom_objects_api.py +++ b/kubernetes/client/api/custom_objects_api.py @@ -296,7 +296,7 @@ def _create_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -335,7 +335,7 @@ def _create_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -612,7 +612,7 @@ def _create_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -653,7 +653,7 @@ def _create_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -930,7 +930,7 @@ def _delete_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -971,7 +971,7 @@ def _delete_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1257,7 +1257,7 @@ def _delete_collection_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1304,7 +1304,7 @@ def _delete_collection_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1608,7 +1608,7 @@ def _delete_collection_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1661,7 +1661,7 @@ def _delete_collection_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -1947,7 +1947,7 @@ def _delete_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1990,7 +1990,7 @@ def _delete_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -2204,7 +2204,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2223,7 +2223,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -2455,7 +2455,7 @@ def _get_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2478,7 +2478,7 @@ def _get_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -2710,7 +2710,7 @@ def _get_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2733,7 +2733,7 @@ def _get_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2967,7 +2967,7 @@ def _get_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2990,7 +2990,7 @@ def _get_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3233,7 +3233,7 @@ def _get_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3258,7 +3258,7 @@ def _get_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -3499,7 +3499,7 @@ def _get_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3524,7 +3524,7 @@ def _get_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3767,7 +3767,7 @@ def _get_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3792,7 +3792,7 @@ def _get_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4107,7 +4107,7 @@ def _list_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4168,7 +4168,7 @@ def _list_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4482,7 +4482,7 @@ def _list_custom_object_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4543,7 +4543,7 @@ def _list_custom_object_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4866,7 +4866,7 @@ def _list_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4929,7 +4929,7 @@ def _list_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5207,7 +5207,7 @@ def _patch_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5248,7 +5248,7 @@ def _patch_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -5257,7 +5257,7 @@ def _patch_cluster_custom_object_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5267,7 +5267,7 @@ def _patch_cluster_custom_object_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5538,7 +5538,7 @@ def _patch_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5579,7 +5579,7 @@ def _patch_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5590,7 +5590,7 @@ def _patch_cluster_custom_object_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5600,7 +5600,7 @@ def _patch_cluster_custom_object_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5871,7 +5871,7 @@ def _patch_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5912,7 +5912,7 @@ def _patch_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5923,7 +5923,7 @@ def _patch_cluster_custom_object_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5933,7 +5933,7 @@ def _patch_cluster_custom_object_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6213,7 +6213,7 @@ def _patch_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6256,7 +6256,7 @@ def _patch_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -6265,7 +6265,7 @@ def _patch_namespaced_custom_object_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6275,7 +6275,7 @@ def _patch_namespaced_custom_object_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6555,7 +6555,7 @@ def _patch_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6598,7 +6598,7 @@ def _patch_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6609,7 +6609,7 @@ def _patch_namespaced_custom_object_scale_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6620,7 +6620,7 @@ def _patch_namespaced_custom_object_scale_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6900,7 +6900,7 @@ def _patch_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6943,7 +6943,7 @@ def _patch_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6954,7 +6954,7 @@ def _patch_namespaced_custom_object_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6965,7 +6965,7 @@ def _patch_namespaced_custom_object_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7227,7 +7227,7 @@ def _replace_cluster_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7264,7 +7264,7 @@ def _replace_cluster_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -7534,7 +7534,7 @@ def _replace_cluster_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7571,7 +7571,7 @@ def _replace_cluster_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7843,7 +7843,7 @@ def _replace_cluster_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7880,7 +7880,7 @@ def _replace_cluster_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8159,7 +8159,7 @@ def _replace_namespaced_custom_object_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8198,7 +8198,7 @@ def _replace_namespaced_custom_object_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' @@ -8477,7 +8477,7 @@ def _replace_namespaced_custom_object_scale_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8516,7 +8516,7 @@ def _replace_namespaced_custom_object_scale_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8797,7 +8797,7 @@ def _replace_namespaced_custom_object_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8836,7 +8836,7 @@ def _replace_namespaced_custom_object_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/discovery_api.py b/kubernetes/client/api/discovery_api.py index 6830f1b49b..c8675f78fb 100644 --- a/kubernetes/client/api/discovery_api.py +++ b/kubernetes/client/api/discovery_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/discovery_v1_api.py b/kubernetes/client/api/discovery_v1_api.py index e12a428224..6af7593cf9 100644 --- a/kubernetes/client/api/discovery_v1_api.py +++ b/kubernetes/client/api/discovery_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_endpoint_slice_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_endpoint_slice_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_endpoint_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_endpoint_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2606,7 +2606,7 @@ def _read_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2629,7 +2629,7 @@ def _read_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2893,7 +2893,7 @@ def _replace_namespaced_endpoint_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2930,7 +2930,7 @@ def _replace_namespaced_endpoint_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/events_api.py b/kubernetes/client/api/events_api.py index 7d84a78524..fb8c75fbb4 100644 --- a/kubernetes/client/api/events_api.py +++ b/kubernetes/client/api/events_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/events_v1_api.py b/kubernetes/client/api/events_v1_api.py index 4449ad9134..cf7d29ed00 100644 --- a/kubernetes/client/api/events_v1_api.py +++ b/kubernetes/client/api/events_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1599,7 +1599,7 @@ def _list_event_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1662,7 +1662,7 @@ def _list_event_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1981,7 +1981,7 @@ def _list_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_event_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_event_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2606,7 +2606,7 @@ def _read_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2629,7 +2629,7 @@ def _read_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2893,7 +2893,7 @@ def _replace_namespaced_event_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2930,7 +2930,7 @@ def _replace_namespaced_event_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/flowcontrol_apiserver_api.py b/kubernetes/client/api/flowcontrol_apiserver_api.py index d7de1116ed..90cd8073dd 100644 --- a/kubernetes/client/api/flowcontrol_apiserver_api.py +++ b/kubernetes/client/api/flowcontrol_apiserver_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/flowcontrol_apiserver_v1_api.py b/kubernetes/client/api/flowcontrol_apiserver_v1_api.py index 725250d5e4..e9a4475493 100644 --- a/kubernetes/client/api/flowcontrol_apiserver_v1_api.py +++ b/kubernetes/client/api/flowcontrol_apiserver_v1_api.py @@ -278,7 +278,7 @@ def _create_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _create_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -559,7 +559,7 @@ def _create_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -592,7 +592,7 @@ def _create_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -935,7 +935,7 @@ def _delete_collection_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1012,7 +1012,7 @@ def _delete_collection_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1355,7 +1355,7 @@ def _delete_collection_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1432,7 +1432,7 @@ def _delete_collection_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1705,7 +1705,7 @@ def _delete_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1748,7 +1748,7 @@ def _delete_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2021,7 +2021,7 @@ def _delete_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2064,7 +2064,7 @@ def _delete_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2263,7 +2263,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2278,7 +2278,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2585,7 +2585,7 @@ def _list_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2648,7 +2648,7 @@ def _list_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2958,7 +2958,7 @@ def _list_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3021,7 +3021,7 @@ def _list_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3288,7 +3288,7 @@ def _patch_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3327,7 +3327,7 @@ def _patch_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3339,7 +3339,7 @@ def _patch_flow_schema_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3353,7 +3353,7 @@ def _patch_flow_schema_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3608,7 +3608,7 @@ def _patch_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3647,7 +3647,7 @@ def _patch_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3659,7 +3659,7 @@ def _patch_flow_schema_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3673,7 +3673,7 @@ def _patch_flow_schema_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3928,7 +3928,7 @@ def _patch_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3967,7 +3967,7 @@ def _patch_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3979,7 +3979,7 @@ def _patch_priority_level_configuration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3993,7 +3993,7 @@ def _patch_priority_level_configuration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4248,7 +4248,7 @@ def _patch_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4287,7 +4287,7 @@ def _patch_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4299,7 +4299,7 @@ def _patch_priority_level_configuration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4313,7 +4313,7 @@ def _patch_priority_level_configuration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4521,7 +4521,7 @@ def _read_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4542,7 +4542,7 @@ def _read_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4759,7 +4759,7 @@ def _read_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4780,7 +4780,7 @@ def _read_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4997,7 +4997,7 @@ def _read_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5018,7 +5018,7 @@ def _read_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5235,7 +5235,7 @@ def _read_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5256,7 +5256,7 @@ def _read_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5511,7 +5511,7 @@ def _replace_flow_schema_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5546,7 +5546,7 @@ def _replace_flow_schema_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5801,7 +5801,7 @@ def _replace_flow_schema_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5836,7 +5836,7 @@ def _replace_flow_schema_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6091,7 +6091,7 @@ def _replace_priority_level_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6126,7 +6126,7 @@ def _replace_priority_level_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6381,7 +6381,7 @@ def _replace_priority_level_configuration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6416,7 +6416,7 @@ def _replace_priority_level_configuration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/internal_apiserver_api.py b/kubernetes/client/api/internal_apiserver_api.py index 5c414eb8fc..8f55255004 100644 --- a/kubernetes/client/api/internal_apiserver_api.py +++ b/kubernetes/client/api/internal_apiserver_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/internal_apiserver_v1alpha1_api.py b/kubernetes/client/api/internal_apiserver_v1alpha1_api.py index e66061b2f8..8c730ff522 100644 --- a/kubernetes/client/api/internal_apiserver_v1alpha1_api.py +++ b/kubernetes/client/api/internal_apiserver_v1alpha1_api.py @@ -276,7 +276,7 @@ def _create_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_storage_version_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_storage_version_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2216,7 +2216,7 @@ def _patch_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2255,7 +2255,7 @@ def _patch_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2267,7 +2267,7 @@ def _patch_storage_version_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2281,7 +2281,7 @@ def _patch_storage_version_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2489,7 +2489,7 @@ def _read_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ def _read_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2727,7 +2727,7 @@ def _read_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2748,7 +2748,7 @@ def _read_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3003,7 +3003,7 @@ def _replace_storage_version_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3038,7 +3038,7 @@ def _replace_storage_version_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3293,7 +3293,7 @@ def _replace_storage_version_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3328,7 +3328,7 @@ def _replace_storage_version_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/lifecycle_api.py b/kubernetes/client/api/lifecycle_api.py index 7584c355f4..47a4b71c96 100644 --- a/kubernetes/client/api/lifecycle_api.py +++ b/kubernetes/client/api/lifecycle_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/lifecycle_v1alpha1_api.py b/kubernetes/client/api/lifecycle_v1alpha1_api.py index 103ec3052e..7d039c4541 100644 --- a/kubernetes/client/api/lifecycle_v1alpha1_api.py +++ b/kubernetes/client/api/lifecycle_v1alpha1_api.py @@ -287,7 +287,7 @@ def _create_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -322,7 +322,7 @@ def _create_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -579,7 +579,7 @@ def _create_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -614,7 +614,7 @@ def _create_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -966,7 +966,7 @@ def _delete_collection_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_collection_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1397,7 +1397,7 @@ def _delete_collection_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1476,7 +1476,7 @@ def _delete_collection_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1758,7 +1758,7 @@ def _delete_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1803,7 +1803,7 @@ def _delete_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2085,7 +2085,7 @@ def _delete_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2130,7 +2130,7 @@ def _delete_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2329,7 +2329,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2344,7 +2344,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2651,7 +2651,7 @@ def _list_eviction_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2714,7 +2714,7 @@ def _list_eviction_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3024,7 +3024,7 @@ def _list_eviction_request_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3087,7 +3087,7 @@ def _list_eviction_request_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3406,7 +3406,7 @@ def _list_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3471,7 +3471,7 @@ def _list_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3790,7 +3790,7 @@ def _list_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3855,7 +3855,7 @@ def _list_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4131,7 +4131,7 @@ def _patch_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4172,7 +4172,7 @@ def _patch_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4184,7 +4184,7 @@ def _patch_namespaced_eviction_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4198,7 +4198,7 @@ def _patch_namespaced_eviction_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4462,7 +4462,7 @@ def _patch_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4503,7 +4503,7 @@ def _patch_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4515,7 +4515,7 @@ def _patch_namespaced_eviction_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4529,7 +4529,7 @@ def _patch_namespaced_eviction_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4793,7 +4793,7 @@ def _patch_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4834,7 +4834,7 @@ def _patch_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4846,7 +4846,7 @@ def _patch_namespaced_eviction_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4860,7 +4860,7 @@ def _patch_namespaced_eviction_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5124,7 +5124,7 @@ def _patch_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5165,7 +5165,7 @@ def _patch_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5177,7 +5177,7 @@ def _patch_namespaced_eviction_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -5191,7 +5191,7 @@ def _patch_namespaced_eviction_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5408,7 +5408,7 @@ def _read_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5431,7 +5431,7 @@ def _read_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5657,7 +5657,7 @@ def _read_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5680,7 +5680,7 @@ def _read_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5906,7 +5906,7 @@ def _read_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5929,7 +5929,7 @@ def _read_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6155,7 +6155,7 @@ def _read_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6178,7 +6178,7 @@ def _read_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6442,7 +6442,7 @@ def _replace_namespaced_eviction_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6479,7 +6479,7 @@ def _replace_namespaced_eviction_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6743,7 +6743,7 @@ def _replace_namespaced_eviction_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6780,7 +6780,7 @@ def _replace_namespaced_eviction_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7044,7 +7044,7 @@ def _replace_namespaced_eviction_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7081,7 +7081,7 @@ def _replace_namespaced_eviction_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7345,7 +7345,7 @@ def _replace_namespaced_eviction_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7382,7 +7382,7 @@ def _replace_namespaced_eviction_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/logs_api.py b/kubernetes/client/api/logs_api.py index b8c30402d8..dde4103259 100644 --- a/kubernetes/client/api/logs_api.py +++ b/kubernetes/client/api/logs_api.py @@ -226,7 +226,7 @@ def _log_file_handler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -428,7 +428,7 @@ def _log_file_list_handler_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] diff --git a/kubernetes/client/api/networking_api.py b/kubernetes/client/api/networking_api.py index f06a8aab1b..f29f067694 100644 --- a/kubernetes/client/api/networking_api.py +++ b/kubernetes/client/api/networking_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/networking_v1_api.py b/kubernetes/client/api/networking_v1_api.py index e275f1afb0..96a90d8b05 100644 --- a/kubernetes/client/api/networking_v1_api.py +++ b/kubernetes/client/api/networking_v1_api.py @@ -284,7 +284,7 @@ def _create_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -317,7 +317,7 @@ def _create_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -565,7 +565,7 @@ def _create_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -598,7 +598,7 @@ def _create_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -855,7 +855,7 @@ def _create_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -890,7 +890,7 @@ def _create_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1147,7 +1147,7 @@ def _create_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1182,7 +1182,7 @@ def _create_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1430,7 +1430,7 @@ def _create_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1463,7 +1463,7 @@ def _create_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1806,7 +1806,7 @@ def _delete_collection_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1883,7 +1883,7 @@ def _delete_collection_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2226,7 +2226,7 @@ def _delete_collection_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2303,7 +2303,7 @@ def _delete_collection_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2655,7 +2655,7 @@ def _delete_collection_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2734,7 +2734,7 @@ def _delete_collection_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3086,7 +3086,7 @@ def _delete_collection_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3165,7 +3165,7 @@ def _delete_collection_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3508,7 +3508,7 @@ def _delete_collection_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ def _delete_collection_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3858,7 +3858,7 @@ def _delete_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3901,7 +3901,7 @@ def _delete_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4174,7 +4174,7 @@ def _delete_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4217,7 +4217,7 @@ def _delete_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4499,7 +4499,7 @@ def _delete_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4544,7 +4544,7 @@ def _delete_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4826,7 +4826,7 @@ def _delete_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4871,7 +4871,7 @@ def _delete_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5144,7 +5144,7 @@ def _delete_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5187,7 +5187,7 @@ def _delete_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5386,7 +5386,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5401,7 +5401,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5708,7 +5708,7 @@ def _list_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5771,7 +5771,7 @@ def _list_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6081,7 +6081,7 @@ def _list_ingress_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6144,7 +6144,7 @@ def _list_ingress_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6454,7 +6454,7 @@ def _list_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6517,7 +6517,7 @@ def _list_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6836,7 +6836,7 @@ def _list_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6901,7 +6901,7 @@ def _list_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7220,7 +7220,7 @@ def _list_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7285,7 +7285,7 @@ def _list_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7595,7 +7595,7 @@ def _list_network_policy_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7658,7 +7658,7 @@ def _list_network_policy_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7968,7 +7968,7 @@ def _list_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8031,7 +8031,7 @@ def _list_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8298,7 +8298,7 @@ def _patch_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8337,7 +8337,7 @@ def _patch_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8349,7 +8349,7 @@ def _patch_ingress_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8363,7 +8363,7 @@ def _patch_ingress_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8618,7 +8618,7 @@ def _patch_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8657,7 +8657,7 @@ def _patch_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8669,7 +8669,7 @@ def _patch_ip_address_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8683,7 +8683,7 @@ def _patch_ip_address_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8947,7 +8947,7 @@ def _patch_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8988,7 +8988,7 @@ def _patch_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9000,7 +9000,7 @@ def _patch_namespaced_ingress_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9014,7 +9014,7 @@ def _patch_namespaced_ingress_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9278,7 +9278,7 @@ def _patch_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9319,7 +9319,7 @@ def _patch_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9331,7 +9331,7 @@ def _patch_namespaced_ingress_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9345,7 +9345,7 @@ def _patch_namespaced_ingress_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9609,7 +9609,7 @@ def _patch_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9650,7 +9650,7 @@ def _patch_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9662,7 +9662,7 @@ def _patch_namespaced_network_policy_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9676,7 +9676,7 @@ def _patch_namespaced_network_policy_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9931,7 +9931,7 @@ def _patch_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9970,7 +9970,7 @@ def _patch_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9982,7 +9982,7 @@ def _patch_service_cidr_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9996,7 +9996,7 @@ def _patch_service_cidr_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10251,7 +10251,7 @@ def _patch_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10290,7 +10290,7 @@ def _patch_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10302,7 +10302,7 @@ def _patch_service_cidr_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10316,7 +10316,7 @@ def _patch_service_cidr_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10524,7 +10524,7 @@ def _read_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10545,7 +10545,7 @@ def _read_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10762,7 +10762,7 @@ def _read_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10783,7 +10783,7 @@ def _read_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11009,7 +11009,7 @@ def _read_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11032,7 +11032,7 @@ def _read_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11258,7 +11258,7 @@ def _read_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11281,7 +11281,7 @@ def _read_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11507,7 +11507,7 @@ def _read_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11530,7 +11530,7 @@ def _read_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11747,7 +11747,7 @@ def _read_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11768,7 +11768,7 @@ def _read_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11985,7 +11985,7 @@ def _read_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12006,7 +12006,7 @@ def _read_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ def _replace_ingress_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12296,7 +12296,7 @@ def _replace_ingress_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12551,7 +12551,7 @@ def _replace_ip_address_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12586,7 +12586,7 @@ def _replace_ip_address_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12850,7 +12850,7 @@ def _replace_namespaced_ingress_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12887,7 +12887,7 @@ def _replace_namespaced_ingress_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13151,7 +13151,7 @@ def _replace_namespaced_ingress_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13188,7 +13188,7 @@ def _replace_namespaced_ingress_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13452,7 +13452,7 @@ def _replace_namespaced_network_policy_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13489,7 +13489,7 @@ def _replace_namespaced_network_policy_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13744,7 +13744,7 @@ def _replace_service_cidr_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13779,7 +13779,7 @@ def _replace_service_cidr_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14034,7 +14034,7 @@ def _replace_service_cidr_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14069,7 +14069,7 @@ def _replace_service_cidr_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/node_api.py b/kubernetes/client/api/node_api.py index c3ae784b6b..835a6a1b9b 100644 --- a/kubernetes/client/api/node_api.py +++ b/kubernetes/client/api/node_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/node_v1_api.py b/kubernetes/client/api/node_v1_api.py index 453fc4806a..ed51b7c58b 100644 --- a/kubernetes/client/api/node_v1_api.py +++ b/kubernetes/client/api/node_v1_api.py @@ -276,7 +276,7 @@ def _create_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_runtime_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_runtime_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2169,7 +2169,7 @@ def _read_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2190,7 +2190,7 @@ def _read_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ def _replace_runtime_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2480,7 +2480,7 @@ def _replace_runtime_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/openid_api.py b/kubernetes/client/api/openid_api.py index 7db6459ac2..90d4ab147c 100644 --- a/kubernetes/client/api/openid_api.py +++ b/kubernetes/client/api/openid_api.py @@ -220,7 +220,7 @@ def _get_service_account_issuer_open_id_keyset_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_service_account_issuer_open_id_keyset_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/jwk-set+json' diff --git a/kubernetes/client/api/policy_api.py b/kubernetes/client/api/policy_api.py index 7e990de781..960c29612b 100644 --- a/kubernetes/client/api/policy_api.py +++ b/kubernetes/client/api/policy_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/policy_v1_api.py b/kubernetes/client/api/policy_v1_api.py index 5bc8ed75d9..e898e528d1 100644 --- a/kubernetes/client/api/policy_v1_api.py +++ b/kubernetes/client/api/policy_v1_api.py @@ -285,7 +285,7 @@ def _create_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -320,7 +320,7 @@ def _create_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -672,7 +672,7 @@ def _delete_collection_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -751,7 +751,7 @@ def _delete_collection_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1033,7 +1033,7 @@ def _delete_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1078,7 +1078,7 @@ def _delete_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1277,7 +1277,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1292,7 +1292,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1608,7 +1608,7 @@ def _list_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1673,7 +1673,7 @@ def _list_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1983,7 +1983,7 @@ def _list_pod_disruption_budget_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2046,7 +2046,7 @@ def _list_pod_disruption_budget_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2322,7 +2322,7 @@ def _patch_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2363,7 +2363,7 @@ def _patch_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2375,7 +2375,7 @@ def _patch_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2389,7 +2389,7 @@ def _patch_namespaced_pod_disruption_budget_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2653,7 +2653,7 @@ def _patch_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2694,7 +2694,7 @@ def _patch_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2706,7 +2706,7 @@ def _patch_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2720,7 +2720,7 @@ def _patch_namespaced_pod_disruption_budget_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2937,7 +2937,7 @@ def _read_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2960,7 +2960,7 @@ def _read_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3186,7 +3186,7 @@ def _read_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3209,7 +3209,7 @@ def _read_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3473,7 +3473,7 @@ def _replace_namespaced_pod_disruption_budget_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3510,7 +3510,7 @@ def _replace_namespaced_pod_disruption_budget_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3774,7 +3774,7 @@ def _replace_namespaced_pod_disruption_budget_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3811,7 +3811,7 @@ def _replace_namespaced_pod_disruption_budget_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/rbac_authorization_api.py b/kubernetes/client/api/rbac_authorization_api.py index f99ae16867..8d51081914 100644 --- a/kubernetes/client/api/rbac_authorization_api.py +++ b/kubernetes/client/api/rbac_authorization_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/rbac_authorization_v1_api.py b/kubernetes/client/api/rbac_authorization_v1_api.py index 2591df034d..e527d0a50b 100644 --- a/kubernetes/client/api/rbac_authorization_v1_api.py +++ b/kubernetes/client/api/rbac_authorization_v1_api.py @@ -282,7 +282,7 @@ def _create_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -315,7 +315,7 @@ def _create_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -563,7 +563,7 @@ def _create_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -596,7 +596,7 @@ def _create_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -853,7 +853,7 @@ def _create_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -888,7 +888,7 @@ def _create_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1145,7 +1145,7 @@ def _create_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1180,7 +1180,7 @@ def _create_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1453,7 +1453,7 @@ def _delete_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1496,7 +1496,7 @@ def _delete_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1769,7 +1769,7 @@ def _delete_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1812,7 +1812,7 @@ def _delete_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2155,7 +2155,7 @@ def _delete_collection_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2232,7 +2232,7 @@ def _delete_collection_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2575,7 +2575,7 @@ def _delete_collection_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2652,7 +2652,7 @@ def _delete_collection_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3004,7 +3004,7 @@ def _delete_collection_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3083,7 +3083,7 @@ def _delete_collection_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3435,7 +3435,7 @@ def _delete_collection_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3514,7 +3514,7 @@ def _delete_collection_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3796,7 +3796,7 @@ def _delete_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3841,7 +3841,7 @@ def _delete_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4123,7 +4123,7 @@ def _delete_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4168,7 +4168,7 @@ def _delete_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4367,7 +4367,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4382,7 +4382,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4689,7 +4689,7 @@ def _list_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4752,7 +4752,7 @@ def _list_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5062,7 +5062,7 @@ def _list_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5125,7 +5125,7 @@ def _list_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5444,7 +5444,7 @@ def _list_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5509,7 +5509,7 @@ def _list_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5828,7 +5828,7 @@ def _list_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5893,7 +5893,7 @@ def _list_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6203,7 +6203,7 @@ def _list_role_binding_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6266,7 +6266,7 @@ def _list_role_binding_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6576,7 +6576,7 @@ def _list_role_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6639,7 +6639,7 @@ def _list_role_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6906,7 +6906,7 @@ def _patch_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6945,7 +6945,7 @@ def _patch_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6957,7 +6957,7 @@ def _patch_cluster_role_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6971,7 +6971,7 @@ def _patch_cluster_role_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7226,7 +7226,7 @@ def _patch_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7265,7 +7265,7 @@ def _patch_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7277,7 +7277,7 @@ def _patch_cluster_role_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7291,7 +7291,7 @@ def _patch_cluster_role_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7555,7 +7555,7 @@ def _patch_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7596,7 +7596,7 @@ def _patch_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7608,7 +7608,7 @@ def _patch_namespaced_role_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7622,7 +7622,7 @@ def _patch_namespaced_role_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7886,7 +7886,7 @@ def _patch_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7927,7 +7927,7 @@ def _patch_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7939,7 +7939,7 @@ def _patch_namespaced_role_binding_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7953,7 +7953,7 @@ def _patch_namespaced_role_binding_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8161,7 +8161,7 @@ def _read_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8182,7 +8182,7 @@ def _read_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8399,7 +8399,7 @@ def _read_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8420,7 +8420,7 @@ def _read_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8646,7 +8646,7 @@ def _read_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8669,7 +8669,7 @@ def _read_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8895,7 +8895,7 @@ def _read_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8918,7 +8918,7 @@ def _read_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9173,7 +9173,7 @@ def _replace_cluster_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9208,7 +9208,7 @@ def _replace_cluster_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9463,7 +9463,7 @@ def _replace_cluster_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9498,7 +9498,7 @@ def _replace_cluster_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9762,7 +9762,7 @@ def _replace_namespaced_role_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9799,7 +9799,7 @@ def _replace_namespaced_role_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10063,7 +10063,7 @@ def _replace_namespaced_role_binding_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10100,7 +10100,7 @@ def _replace_namespaced_role_binding_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/resource_api.py b/kubernetes/client/api/resource_api.py index 48aced89de..895230b9b1 100644 --- a/kubernetes/client/api/resource_api.py +++ b/kubernetes/client/api/resource_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/resource_v1_api.py b/kubernetes/client/api/resource_v1_api.py index 65b4594393..552e0a8cc2 100644 --- a/kubernetes/client/api/resource_v1_api.py +++ b/kubernetes/client/api/resource_v1_api.py @@ -284,7 +284,7 @@ def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -317,7 +317,7 @@ def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -565,7 +565,7 @@ def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -598,7 +598,7 @@ def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -855,7 +855,7 @@ def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -890,7 +890,7 @@ def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1147,7 +1147,7 @@ def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1182,7 +1182,7 @@ def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1430,7 +1430,7 @@ def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1463,7 +1463,7 @@ def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1806,7 +1806,7 @@ def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1883,7 +1883,7 @@ def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2226,7 +2226,7 @@ def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2303,7 +2303,7 @@ def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2655,7 +2655,7 @@ def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2734,7 +2734,7 @@ def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3086,7 +3086,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3165,7 +3165,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3508,7 +3508,7 @@ def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3858,7 +3858,7 @@ def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3901,7 +3901,7 @@ def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4174,7 +4174,7 @@ def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4217,7 +4217,7 @@ def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4499,7 +4499,7 @@ def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4544,7 +4544,7 @@ def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4826,7 +4826,7 @@ def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4871,7 +4871,7 @@ def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5144,7 +5144,7 @@ def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5187,7 +5187,7 @@ def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5386,7 +5386,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5401,7 +5401,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5708,7 +5708,7 @@ def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5771,7 +5771,7 @@ def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6081,7 +6081,7 @@ def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6144,7 +6144,7 @@ def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6463,7 +6463,7 @@ def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6528,7 +6528,7 @@ def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6847,7 +6847,7 @@ def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6912,7 +6912,7 @@ def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7222,7 +7222,7 @@ def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7285,7 +7285,7 @@ def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7595,7 +7595,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7658,7 +7658,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7968,7 +7968,7 @@ def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8031,7 +8031,7 @@ def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8298,7 +8298,7 @@ def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8337,7 +8337,7 @@ def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8349,7 +8349,7 @@ def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8363,7 +8363,7 @@ def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8618,7 +8618,7 @@ def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8657,7 +8657,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8669,7 +8669,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8683,7 +8683,7 @@ def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8938,7 +8938,7 @@ def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8977,7 +8977,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8989,7 +8989,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9003,7 +9003,7 @@ def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9267,7 +9267,7 @@ def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9308,7 +9308,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9320,7 +9320,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9334,7 +9334,7 @@ def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9598,7 +9598,7 @@ def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9639,7 +9639,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9651,7 +9651,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9665,7 +9665,7 @@ def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9929,7 +9929,7 @@ def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9970,7 +9970,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9982,7 +9982,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9996,7 +9996,7 @@ def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10251,7 +10251,7 @@ def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10290,7 +10290,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10302,7 +10302,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10316,7 +10316,7 @@ def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10524,7 +10524,7 @@ def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10545,7 +10545,7 @@ def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10762,7 +10762,7 @@ def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10783,7 +10783,7 @@ def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11000,7 +11000,7 @@ def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11021,7 +11021,7 @@ def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11247,7 +11247,7 @@ def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11270,7 +11270,7 @@ def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11496,7 +11496,7 @@ def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11519,7 +11519,7 @@ def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11745,7 +11745,7 @@ def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11768,7 +11768,7 @@ def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11985,7 +11985,7 @@ def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12006,7 +12006,7 @@ def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12296,7 +12296,7 @@ def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12551,7 +12551,7 @@ def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12586,7 +12586,7 @@ def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12841,7 +12841,7 @@ def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12876,7 +12876,7 @@ def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13140,7 +13140,7 @@ def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13177,7 +13177,7 @@ def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13441,7 +13441,7 @@ def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13478,7 +13478,7 @@ def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13742,7 +13742,7 @@ def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13779,7 +13779,7 @@ def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14034,7 +14034,7 @@ def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14069,7 +14069,7 @@ def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/resource_v1alpha3_api.py b/kubernetes/client/api/resource_v1alpha3_api.py index 7d2f339b6f..347f669de0 100644 --- a/kubernetes/client/api/resource_v1alpha3_api.py +++ b/kubernetes/client/api/resource_v1alpha3_api.py @@ -278,7 +278,7 @@ def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -311,7 +311,7 @@ def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -559,7 +559,7 @@ def _create_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -592,7 +592,7 @@ def _create_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -935,7 +935,7 @@ def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1012,7 +1012,7 @@ def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1355,7 +1355,7 @@ def _delete_collection_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1432,7 +1432,7 @@ def _delete_collection_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1705,7 +1705,7 @@ def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1748,7 +1748,7 @@ def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2021,7 +2021,7 @@ def _delete_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2064,7 +2064,7 @@ def _delete_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2263,7 +2263,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2278,7 +2278,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2585,7 +2585,7 @@ def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2648,7 +2648,7 @@ def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2958,7 +2958,7 @@ def _list_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3021,7 +3021,7 @@ def _list_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3288,7 +3288,7 @@ def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3327,7 +3327,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3339,7 +3339,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3353,7 +3353,7 @@ def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3608,7 +3608,7 @@ def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3647,7 +3647,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3659,7 +3659,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3673,7 +3673,7 @@ def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -3928,7 +3928,7 @@ def _patch_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3967,7 +3967,7 @@ def _patch_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3979,7 +3979,7 @@ def _patch_resource_pool_status_request_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -3993,7 +3993,7 @@ def _patch_resource_pool_status_request_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4248,7 +4248,7 @@ def _patch_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4287,7 +4287,7 @@ def _patch_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4299,7 +4299,7 @@ def _patch_resource_pool_status_request_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4313,7 +4313,7 @@ def _patch_resource_pool_status_request_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4521,7 +4521,7 @@ def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4542,7 +4542,7 @@ def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4759,7 +4759,7 @@ def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4780,7 +4780,7 @@ def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4997,7 +4997,7 @@ def _read_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5018,7 +5018,7 @@ def _read_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5235,7 +5235,7 @@ def _read_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5256,7 +5256,7 @@ def _read_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5511,7 +5511,7 @@ def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5546,7 +5546,7 @@ def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5801,7 +5801,7 @@ def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5836,7 +5836,7 @@ def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6091,7 +6091,7 @@ def _replace_resource_pool_status_request_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6126,7 +6126,7 @@ def _replace_resource_pool_status_request_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6381,7 +6381,7 @@ def _replace_resource_pool_status_request_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6416,7 +6416,7 @@ def _replace_resource_pool_status_request_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/resource_v1beta1_api.py b/kubernetes/client/api/resource_v1beta1_api.py index 2b34c1c166..ac5a05c358 100644 --- a/kubernetes/client/api/resource_v1beta1_api.py +++ b/kubernetes/client/api/resource_v1beta1_api.py @@ -282,7 +282,7 @@ def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -315,7 +315,7 @@ def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -572,7 +572,7 @@ def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -607,7 +607,7 @@ def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -864,7 +864,7 @@ def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -899,7 +899,7 @@ def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1147,7 +1147,7 @@ def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1180,7 +1180,7 @@ def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1523,7 +1523,7 @@ def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1600,7 +1600,7 @@ def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1952,7 +1952,7 @@ def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2031,7 +2031,7 @@ def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2383,7 +2383,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2462,7 +2462,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2805,7 +2805,7 @@ def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2882,7 +2882,7 @@ def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3155,7 +3155,7 @@ def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3198,7 +3198,7 @@ def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3480,7 +3480,7 @@ def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3525,7 +3525,7 @@ def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3807,7 +3807,7 @@ def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3852,7 +3852,7 @@ def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4125,7 +4125,7 @@ def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4168,7 +4168,7 @@ def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4367,7 +4367,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4382,7 +4382,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4689,7 +4689,7 @@ def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4752,7 +4752,7 @@ def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5071,7 +5071,7 @@ def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5136,7 +5136,7 @@ def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5455,7 +5455,7 @@ def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5520,7 +5520,7 @@ def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5830,7 +5830,7 @@ def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5893,7 +5893,7 @@ def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6203,7 +6203,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6266,7 +6266,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6576,7 +6576,7 @@ def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6639,7 +6639,7 @@ def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6906,7 +6906,7 @@ def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6945,7 +6945,7 @@ def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6957,7 +6957,7 @@ def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6971,7 +6971,7 @@ def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7235,7 +7235,7 @@ def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7276,7 +7276,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7288,7 +7288,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7302,7 +7302,7 @@ def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7566,7 +7566,7 @@ def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7607,7 +7607,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7619,7 +7619,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7633,7 +7633,7 @@ def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7897,7 +7897,7 @@ def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7938,7 +7938,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7950,7 +7950,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7964,7 +7964,7 @@ def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8219,7 +8219,7 @@ def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8258,7 +8258,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8270,7 +8270,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8284,7 +8284,7 @@ def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8492,7 +8492,7 @@ def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8513,7 +8513,7 @@ def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8739,7 +8739,7 @@ def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8762,7 +8762,7 @@ def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8988,7 +8988,7 @@ def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9011,7 +9011,7 @@ def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9237,7 +9237,7 @@ def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9260,7 +9260,7 @@ def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9477,7 +9477,7 @@ def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9498,7 +9498,7 @@ def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9753,7 +9753,7 @@ def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9788,7 +9788,7 @@ def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10052,7 +10052,7 @@ def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10089,7 +10089,7 @@ def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10353,7 +10353,7 @@ def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10390,7 +10390,7 @@ def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10654,7 +10654,7 @@ def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10691,7 +10691,7 @@ def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10946,7 +10946,7 @@ def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10981,7 +10981,7 @@ def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/resource_v1beta2_api.py b/kubernetes/client/api/resource_v1beta2_api.py index 0bf08d5244..cdb6faaf4f 100644 --- a/kubernetes/client/api/resource_v1beta2_api.py +++ b/kubernetes/client/api/resource_v1beta2_api.py @@ -284,7 +284,7 @@ def _create_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -317,7 +317,7 @@ def _create_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -565,7 +565,7 @@ def _create_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -598,7 +598,7 @@ def _create_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -855,7 +855,7 @@ def _create_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -890,7 +890,7 @@ def _create_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1147,7 +1147,7 @@ def _create_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1182,7 +1182,7 @@ def _create_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1430,7 +1430,7 @@ def _create_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1463,7 +1463,7 @@ def _create_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1806,7 +1806,7 @@ def _delete_collection_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1883,7 +1883,7 @@ def _delete_collection_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2226,7 +2226,7 @@ def _delete_collection_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2303,7 +2303,7 @@ def _delete_collection_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2655,7 +2655,7 @@ def _delete_collection_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2734,7 +2734,7 @@ def _delete_collection_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3086,7 +3086,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3165,7 +3165,7 @@ def _delete_collection_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3508,7 +3508,7 @@ def _delete_collection_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3585,7 +3585,7 @@ def _delete_collection_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3858,7 +3858,7 @@ def _delete_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3901,7 +3901,7 @@ def _delete_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4174,7 +4174,7 @@ def _delete_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4217,7 +4217,7 @@ def _delete_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4499,7 +4499,7 @@ def _delete_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4544,7 +4544,7 @@ def _delete_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4826,7 +4826,7 @@ def _delete_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4871,7 +4871,7 @@ def _delete_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5144,7 +5144,7 @@ def _delete_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5187,7 +5187,7 @@ def _delete_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5386,7 +5386,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5401,7 +5401,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5708,7 +5708,7 @@ def _list_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5771,7 +5771,7 @@ def _list_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6081,7 +6081,7 @@ def _list_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6144,7 +6144,7 @@ def _list_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6463,7 +6463,7 @@ def _list_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6528,7 +6528,7 @@ def _list_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6847,7 +6847,7 @@ def _list_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6912,7 +6912,7 @@ def _list_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7222,7 +7222,7 @@ def _list_resource_claim_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7285,7 +7285,7 @@ def _list_resource_claim_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7595,7 +7595,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7658,7 +7658,7 @@ def _list_resource_claim_template_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7968,7 +7968,7 @@ def _list_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8031,7 +8031,7 @@ def _list_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8298,7 +8298,7 @@ def _patch_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8337,7 +8337,7 @@ def _patch_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8349,7 +8349,7 @@ def _patch_device_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8363,7 +8363,7 @@ def _patch_device_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8618,7 +8618,7 @@ def _patch_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8657,7 +8657,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8669,7 +8669,7 @@ def _patch_device_taint_rule_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -8683,7 +8683,7 @@ def _patch_device_taint_rule_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -8938,7 +8938,7 @@ def _patch_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8977,7 +8977,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8989,7 +8989,7 @@ def _patch_device_taint_rule_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9003,7 +9003,7 @@ def _patch_device_taint_rule_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9267,7 +9267,7 @@ def _patch_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9308,7 +9308,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9320,7 +9320,7 @@ def _patch_namespaced_resource_claim_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9334,7 +9334,7 @@ def _patch_namespaced_resource_claim_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9598,7 +9598,7 @@ def _patch_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9639,7 +9639,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9651,7 +9651,7 @@ def _patch_namespaced_resource_claim_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9665,7 +9665,7 @@ def _patch_namespaced_resource_claim_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9929,7 +9929,7 @@ def _patch_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9970,7 +9970,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9982,7 +9982,7 @@ def _patch_namespaced_resource_claim_template_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9996,7 +9996,7 @@ def _patch_namespaced_resource_claim_template_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10251,7 +10251,7 @@ def _patch_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10290,7 +10290,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10302,7 +10302,7 @@ def _patch_resource_slice_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10316,7 +10316,7 @@ def _patch_resource_slice_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10524,7 +10524,7 @@ def _read_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10545,7 +10545,7 @@ def _read_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10762,7 +10762,7 @@ def _read_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10783,7 +10783,7 @@ def _read_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11000,7 +11000,7 @@ def _read_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11021,7 +11021,7 @@ def _read_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11247,7 +11247,7 @@ def _read_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11270,7 +11270,7 @@ def _read_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11496,7 +11496,7 @@ def _read_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11519,7 +11519,7 @@ def _read_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11745,7 +11745,7 @@ def _read_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11768,7 +11768,7 @@ def _read_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11985,7 +11985,7 @@ def _read_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12006,7 +12006,7 @@ def _read_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12261,7 +12261,7 @@ def _replace_device_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12296,7 +12296,7 @@ def _replace_device_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12551,7 +12551,7 @@ def _replace_device_taint_rule_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12586,7 +12586,7 @@ def _replace_device_taint_rule_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12841,7 +12841,7 @@ def _replace_device_taint_rule_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12876,7 +12876,7 @@ def _replace_device_taint_rule_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13140,7 +13140,7 @@ def _replace_namespaced_resource_claim_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13177,7 +13177,7 @@ def _replace_namespaced_resource_claim_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13441,7 +13441,7 @@ def _replace_namespaced_resource_claim_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13478,7 +13478,7 @@ def _replace_namespaced_resource_claim_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13742,7 +13742,7 @@ def _replace_namespaced_resource_claim_template_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13779,7 +13779,7 @@ def _replace_namespaced_resource_claim_template_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14034,7 +14034,7 @@ def _replace_resource_slice_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14069,7 +14069,7 @@ def _replace_resource_slice_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/scheduling_api.py b/kubernetes/client/api/scheduling_api.py index 0c3ba5f2ac..8b7197c820 100644 --- a/kubernetes/client/api/scheduling_api.py +++ b/kubernetes/client/api/scheduling_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/scheduling_v1_api.py b/kubernetes/client/api/scheduling_v1_api.py index 420100cd92..e63c42d26e 100644 --- a/kubernetes/client/api/scheduling_v1_api.py +++ b/kubernetes/client/api/scheduling_v1_api.py @@ -276,7 +276,7 @@ def _create_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_priority_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_priority_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2169,7 +2169,7 @@ def _read_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2190,7 +2190,7 @@ def _read_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2445,7 +2445,7 @@ def _replace_priority_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2480,7 +2480,7 @@ def _replace_priority_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/scheduling_v1alpha3_api.py b/kubernetes/client/api/scheduling_v1alpha3_api.py index 2b725dc79a..f3abe45231 100644 --- a/kubernetes/client/api/scheduling_v1alpha3_api.py +++ b/kubernetes/client/api/scheduling_v1alpha3_api.py @@ -289,7 +289,7 @@ def _create_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -324,7 +324,7 @@ def _create_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -581,7 +581,7 @@ def _create_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -616,7 +616,7 @@ def _create_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -873,7 +873,7 @@ def _create_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -908,7 +908,7 @@ def _create_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1260,7 +1260,7 @@ def _delete_collection_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1339,7 +1339,7 @@ def _delete_collection_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1691,7 +1691,7 @@ def _delete_collection_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1770,7 +1770,7 @@ def _delete_collection_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2122,7 +2122,7 @@ def _delete_collection_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2201,7 +2201,7 @@ def _delete_collection_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2483,7 +2483,7 @@ def _delete_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2528,7 +2528,7 @@ def _delete_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2810,7 +2810,7 @@ def _delete_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2855,7 +2855,7 @@ def _delete_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3137,7 +3137,7 @@ def _delete_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3182,7 +3182,7 @@ def _delete_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3381,7 +3381,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3396,7 +3396,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3703,7 +3703,7 @@ def _list_composite_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3766,7 +3766,7 @@ def _list_composite_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4085,7 +4085,7 @@ def _list_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4150,7 +4150,7 @@ def _list_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4469,7 +4469,7 @@ def _list_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4534,7 +4534,7 @@ def _list_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4853,7 +4853,7 @@ def _list_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4918,7 +4918,7 @@ def _list_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5228,7 +5228,7 @@ def _list_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5291,7 +5291,7 @@ def _list_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5601,7 +5601,7 @@ def _list_workload_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5664,7 +5664,7 @@ def _list_workload_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5940,7 +5940,7 @@ def _patch_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5981,7 +5981,7 @@ def _patch_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5993,7 +5993,7 @@ def _patch_namespaced_composite_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6007,7 +6007,7 @@ def _patch_namespaced_composite_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6271,7 +6271,7 @@ def _patch_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6312,7 +6312,7 @@ def _patch_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6324,7 +6324,7 @@ def _patch_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6338,7 +6338,7 @@ def _patch_namespaced_composite_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6602,7 +6602,7 @@ def _patch_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6643,7 +6643,7 @@ def _patch_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6655,7 +6655,7 @@ def _patch_namespaced_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -6669,7 +6669,7 @@ def _patch_namespaced_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -6933,7 +6933,7 @@ def _patch_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6974,7 +6974,7 @@ def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6986,7 +6986,7 @@ def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7000,7 +7000,7 @@ def _patch_namespaced_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7264,7 +7264,7 @@ def _patch_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7305,7 +7305,7 @@ def _patch_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7317,7 +7317,7 @@ def _patch_namespaced_workload_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -7331,7 +7331,7 @@ def _patch_namespaced_workload_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -7548,7 +7548,7 @@ def _read_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7571,7 +7571,7 @@ def _read_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7797,7 +7797,7 @@ def _read_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7820,7 +7820,7 @@ def _read_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8046,7 +8046,7 @@ def _read_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8069,7 +8069,7 @@ def _read_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8295,7 +8295,7 @@ def _read_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8318,7 +8318,7 @@ def _read_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8544,7 +8544,7 @@ def _read_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8567,7 +8567,7 @@ def _read_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8831,7 +8831,7 @@ def _replace_namespaced_composite_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8868,7 +8868,7 @@ def _replace_namespaced_composite_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9132,7 +9132,7 @@ def _replace_namespaced_composite_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9169,7 +9169,7 @@ def _replace_namespaced_composite_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9433,7 +9433,7 @@ def _replace_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9470,7 +9470,7 @@ def _replace_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9734,7 +9734,7 @@ def _replace_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9771,7 +9771,7 @@ def _replace_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10035,7 +10035,7 @@ def _replace_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10072,7 +10072,7 @@ def _replace_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/scheduling_v1beta1_api.py b/kubernetes/client/api/scheduling_v1beta1_api.py index 87d3ad6134..4ec31f0cf7 100644 --- a/kubernetes/client/api/scheduling_v1beta1_api.py +++ b/kubernetes/client/api/scheduling_v1beta1_api.py @@ -287,7 +287,7 @@ def _create_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -322,7 +322,7 @@ def _create_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -579,7 +579,7 @@ def _create_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -614,7 +614,7 @@ def _create_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -966,7 +966,7 @@ def _delete_collection_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_collection_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1397,7 +1397,7 @@ def _delete_collection_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1476,7 +1476,7 @@ def _delete_collection_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1758,7 +1758,7 @@ def _delete_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1803,7 +1803,7 @@ def _delete_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2085,7 +2085,7 @@ def _delete_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2130,7 +2130,7 @@ def _delete_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2329,7 +2329,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2344,7 +2344,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2660,7 +2660,7 @@ def _list_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2725,7 +2725,7 @@ def _list_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3044,7 +3044,7 @@ def _list_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3109,7 +3109,7 @@ def _list_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3419,7 +3419,7 @@ def _list_pod_group_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3482,7 +3482,7 @@ def _list_pod_group_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3792,7 +3792,7 @@ def _list_workload_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3855,7 +3855,7 @@ def _list_workload_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4131,7 +4131,7 @@ def _patch_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4172,7 +4172,7 @@ def _patch_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4184,7 +4184,7 @@ def _patch_namespaced_pod_group_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4198,7 +4198,7 @@ def _patch_namespaced_pod_group_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4462,7 +4462,7 @@ def _patch_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4503,7 +4503,7 @@ def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4515,7 +4515,7 @@ def _patch_namespaced_pod_group_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4529,7 +4529,7 @@ def _patch_namespaced_pod_group_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -4793,7 +4793,7 @@ def _patch_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4834,7 +4834,7 @@ def _patch_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4846,7 +4846,7 @@ def _patch_namespaced_workload_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -4860,7 +4860,7 @@ def _patch_namespaced_workload_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -5077,7 +5077,7 @@ def _read_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5100,7 +5100,7 @@ def _read_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5326,7 +5326,7 @@ def _read_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5349,7 +5349,7 @@ def _read_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5575,7 +5575,7 @@ def _read_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5598,7 +5598,7 @@ def _read_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5862,7 +5862,7 @@ def _replace_namespaced_pod_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5899,7 +5899,7 @@ def _replace_namespaced_pod_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6163,7 +6163,7 @@ def _replace_namespaced_pod_group_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6200,7 +6200,7 @@ def _replace_namespaced_pod_group_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6464,7 +6464,7 @@ def _replace_namespaced_workload_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6501,7 +6501,7 @@ def _replace_namespaced_workload_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/storage_api.py b/kubernetes/client/api/storage_api.py index 68822f846f..183ea3aafe 100644 --- a/kubernetes/client/api/storage_api.py +++ b/kubernetes/client/api/storage_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/storage_v1_api.py b/kubernetes/client/api/storage_v1_api.py index 1a5b473942..b918adce05 100644 --- a/kubernetes/client/api/storage_v1_api.py +++ b/kubernetes/client/api/storage_v1_api.py @@ -286,7 +286,7 @@ def _create_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -319,7 +319,7 @@ def _create_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -567,7 +567,7 @@ def _create_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -600,7 +600,7 @@ def _create_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -857,7 +857,7 @@ def _create_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -892,7 +892,7 @@ def _create_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1140,7 +1140,7 @@ def _create_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1173,7 +1173,7 @@ def _create_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1421,7 +1421,7 @@ def _create_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1454,7 +1454,7 @@ def _create_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1702,7 +1702,7 @@ def _create_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1735,7 +1735,7 @@ def _create_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2078,7 +2078,7 @@ def _delete_collection_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2155,7 +2155,7 @@ def _delete_collection_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2498,7 +2498,7 @@ def _delete_collection_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2575,7 +2575,7 @@ def _delete_collection_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2927,7 +2927,7 @@ def _delete_collection_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3006,7 +3006,7 @@ def _delete_collection_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3349,7 +3349,7 @@ def _delete_collection_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3426,7 +3426,7 @@ def _delete_collection_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3769,7 +3769,7 @@ def _delete_collection_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3846,7 +3846,7 @@ def _delete_collection_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4189,7 +4189,7 @@ def _delete_collection_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4266,7 +4266,7 @@ def _delete_collection_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4539,7 +4539,7 @@ def _delete_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4582,7 +4582,7 @@ def _delete_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -4855,7 +4855,7 @@ def _delete_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -4898,7 +4898,7 @@ def _delete_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5180,7 +5180,7 @@ def _delete_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5225,7 +5225,7 @@ def _delete_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5498,7 +5498,7 @@ def _delete_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5541,7 +5541,7 @@ def _delete_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -5814,7 +5814,7 @@ def _delete_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -5857,7 +5857,7 @@ def _delete_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6130,7 +6130,7 @@ def _delete_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6173,7 +6173,7 @@ def _delete_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6372,7 +6372,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6387,7 +6387,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -6694,7 +6694,7 @@ def _list_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -6757,7 +6757,7 @@ def _list_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7067,7 +7067,7 @@ def _list_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7130,7 +7130,7 @@ def _list_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7440,7 +7440,7 @@ def _list_csi_storage_capacity_for_all_namespaces_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7503,7 +7503,7 @@ def _list_csi_storage_capacity_for_all_namespaces_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -7822,7 +7822,7 @@ def _list_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -7887,7 +7887,7 @@ def _list_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8197,7 +8197,7 @@ def _list_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8260,7 +8260,7 @@ def _list_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8570,7 +8570,7 @@ def _list_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -8633,7 +8633,7 @@ def _list_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -8943,7 +8943,7 @@ def _list_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9006,7 +9006,7 @@ def _list_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9273,7 +9273,7 @@ def _patch_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9312,7 +9312,7 @@ def _patch_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9324,7 +9324,7 @@ def _patch_csi_driver_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9338,7 +9338,7 @@ def _patch_csi_driver_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9593,7 +9593,7 @@ def _patch_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9632,7 +9632,7 @@ def _patch_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9644,7 +9644,7 @@ def _patch_csi_node_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9658,7 +9658,7 @@ def _patch_csi_node_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -9913,7 +9913,7 @@ def _patch_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -9952,7 +9952,7 @@ def _patch_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -9964,7 +9964,7 @@ def _patch_csi_node_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -9978,7 +9978,7 @@ def _patch_csi_node_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10242,7 +10242,7 @@ def _patch_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10283,7 +10283,7 @@ def _patch_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10295,7 +10295,7 @@ def _patch_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10309,7 +10309,7 @@ def _patch_namespaced_csi_storage_capacity_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10564,7 +10564,7 @@ def _patch_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10603,7 +10603,7 @@ def _patch_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10615,7 +10615,7 @@ def _patch_storage_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10629,7 +10629,7 @@ def _patch_storage_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -10884,7 +10884,7 @@ def _patch_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -10923,7 +10923,7 @@ def _patch_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -10935,7 +10935,7 @@ def _patch_volume_attachment_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -10949,7 +10949,7 @@ def _patch_volume_attachment_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11204,7 +11204,7 @@ def _patch_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11243,7 +11243,7 @@ def _patch_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11255,7 +11255,7 @@ def _patch_volume_attachment_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11269,7 +11269,7 @@ def _patch_volume_attachment_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11524,7 +11524,7 @@ def _patch_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11563,7 +11563,7 @@ def _patch_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -11575,7 +11575,7 @@ def _patch_volume_attributes_class_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -11589,7 +11589,7 @@ def _patch_volume_attributes_class_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -11797,7 +11797,7 @@ def _read_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -11818,7 +11818,7 @@ def _read_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12035,7 +12035,7 @@ def _read_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12056,7 +12056,7 @@ def _read_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12273,7 +12273,7 @@ def _read_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12294,7 +12294,7 @@ def _read_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12520,7 +12520,7 @@ def _read_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12543,7 +12543,7 @@ def _read_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12760,7 +12760,7 @@ def _read_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -12781,7 +12781,7 @@ def _read_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -12998,7 +12998,7 @@ def _read_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13019,7 +13019,7 @@ def _read_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13236,7 +13236,7 @@ def _read_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13257,7 +13257,7 @@ def _read_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13474,7 +13474,7 @@ def _read_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13495,7 +13495,7 @@ def _read_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -13750,7 +13750,7 @@ def _replace_csi_driver_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -13785,7 +13785,7 @@ def _replace_csi_driver_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14040,7 +14040,7 @@ def _replace_csi_node_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14075,7 +14075,7 @@ def _replace_csi_node_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14330,7 +14330,7 @@ def _replace_csi_node_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14365,7 +14365,7 @@ def _replace_csi_node_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14629,7 +14629,7 @@ def _replace_namespaced_csi_storage_capacity_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14666,7 +14666,7 @@ def _replace_namespaced_csi_storage_capacity_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -14921,7 +14921,7 @@ def _replace_storage_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -14956,7 +14956,7 @@ def _replace_storage_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15211,7 +15211,7 @@ def _replace_volume_attachment_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15246,7 +15246,7 @@ def _replace_volume_attachment_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15501,7 +15501,7 @@ def _replace_volume_attachment_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15536,7 +15536,7 @@ def _replace_volume_attachment_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -15791,7 +15791,7 @@ def _replace_volume_attributes_class_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -15826,7 +15826,7 @@ def _replace_volume_attributes_class_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/storagemigration_api.py b/kubernetes/client/api/storagemigration_api.py index 44efabef84..f1e1a10ec7 100644 --- a/kubernetes/client/api/storagemigration_api.py +++ b/kubernetes/client/api/storagemigration_api.py @@ -220,7 +220,7 @@ def _get_api_group_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_api_group_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/storagemigration_v1_api.py b/kubernetes/client/api/storagemigration_v1_api.py index 03802dfb58..0d28c2634b 100644 --- a/kubernetes/client/api/storagemigration_v1_api.py +++ b/kubernetes/client/api/storagemigration_v1_api.py @@ -276,7 +276,7 @@ def _create_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_storage_version_migration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_storage_version_migration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2216,7 +2216,7 @@ def _patch_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2255,7 +2255,7 @@ def _patch_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2267,7 +2267,7 @@ def _patch_storage_version_migration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2281,7 +2281,7 @@ def _patch_storage_version_migration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2489,7 +2489,7 @@ def _read_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ def _read_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2727,7 +2727,7 @@ def _read_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2748,7 +2748,7 @@ def _read_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3003,7 +3003,7 @@ def _replace_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3038,7 +3038,7 @@ def _replace_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3293,7 +3293,7 @@ def _replace_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3328,7 +3328,7 @@ def _replace_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/storagemigration_v1beta1_api.py b/kubernetes/client/api/storagemigration_v1beta1_api.py index 0552a0a611..a5873fe113 100644 --- a/kubernetes/client/api/storagemigration_v1beta1_api.py +++ b/kubernetes/client/api/storagemigration_v1beta1_api.py @@ -276,7 +276,7 @@ def _create_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -309,7 +309,7 @@ def _create_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -652,7 +652,7 @@ def _delete_collection_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -729,7 +729,7 @@ def _delete_collection_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1002,7 +1002,7 @@ def _delete_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1045,7 +1045,7 @@ def _delete_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1244,7 +1244,7 @@ def _get_api_resources_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1259,7 +1259,7 @@ def _get_api_resources_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1566,7 +1566,7 @@ def _list_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1629,7 +1629,7 @@ def _list_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1896,7 +1896,7 @@ def _patch_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -1935,7 +1935,7 @@ def _patch_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -1947,7 +1947,7 @@ def _patch_storage_version_migration_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -1961,7 +1961,7 @@ def _patch_storage_version_migration_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2216,7 +2216,7 @@ def _patch_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2255,7 +2255,7 @@ def _patch_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2267,7 +2267,7 @@ def _patch_storage_version_migration_status_serialize( # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + self.api_client._set_header(_header_params, 'Content-Type', _content_type) else: _default_content_type = ( self.api_client.select_header_content_type( @@ -2281,7 +2281,7 @@ def _patch_storage_version_migration_status_serialize( ) ) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + self.api_client._set_header(_header_params, 'Content-Type', _default_content_type) # authentication setting _auth_settings: List[str] = [ @@ -2489,7 +2489,7 @@ def _read_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2510,7 +2510,7 @@ def _read_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -2727,7 +2727,7 @@ def _read_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -2748,7 +2748,7 @@ def _read_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3003,7 +3003,7 @@ def _replace_storage_version_migration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3038,7 +3038,7 @@ def _replace_storage_version_migration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', @@ -3293,7 +3293,7 @@ def _replace_storage_version_migration_status_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -3328,7 +3328,7 @@ def _replace_storage_version_migration_status_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json', diff --git a/kubernetes/client/api/version_api.py b/kubernetes/client/api/version_api.py index 025698d89c..bfa3ed5256 100644 --- a/kubernetes/client/api/version_api.py +++ b/kubernetes/client/api/version_api.py @@ -220,7 +220,7 @@ def _get_code_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_code_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' diff --git a/kubernetes/client/api/well_known_api.py b/kubernetes/client/api/well_known_api.py index 434362d6a1..c9088b9487 100644 --- a/kubernetes/client/api/well_known_api.py +++ b/kubernetes/client/api/well_known_api.py @@ -220,7 +220,7 @@ def _get_service_account_issuer_open_id_configuration_serialize( _path_params: Dict[str, str] = {} _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} + _header_params: Dict[str, Any] = self.api_client._merge_headers(_headers) _form_params: List[Tuple[str, str]] = [] _files: Dict[ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] @@ -235,7 +235,7 @@ def _get_service_account_issuer_open_id_configuration_serialize( # set the HTTP header `Accept` - if 'Accept' not in _header_params: + if not any(key.lower() == 'accept' for key in _header_params): _header_params['Accept'] = self.api_client.select_header_accept( [ 'application/json' diff --git a/kubernetes/client/api_client.py b/kubernetes/client/api_client.py index 40eaa6ea65..f7634005cf 100644 --- a/kubernetes/client/api_client.py +++ b/kubernetes/client/api_client.py @@ -26,7 +26,7 @@ from threading import Lock from urllib.parse import quote -from typing import Tuple, Optional, List, Dict, Union, Any +from typing import Any, Tuple, Optional, List, Dict, Union from pydantic import SecretStr from kubernetes.client.configuration import Configuration @@ -44,34 +44,7 @@ ) -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict +from kubernetes.client._legacy_model_helpers import _get_openapi_to_dict RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] @@ -210,15 +183,35 @@ def __exit__(self, exc_type, exc_value, traceback): @property def user_agent(self): """User agent for this API client""" - return self.default_headers['User-Agent'] + for name, value in reversed(self.default_headers.items()): + if name.lower() == 'user-agent': + return value + raise KeyError('User-Agent') @user_agent.setter def user_agent(self, value): - self.default_headers['User-Agent'] = value + self._set_header(self.default_headers, 'User-Agent', value) def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value + self._set_header(self.default_headers, header_name, header_value) + + @staticmethod + def _set_header(headers: Dict[str, Any], name: str, value: Any) -> None: + """Replace a header case-insensitively, retaining the winning spelling.""" + for key in list(headers): + if key.lower() == name.lower(): + del headers[key] + headers[name] = value + + @classmethod + def _merge_headers(cls, *sources: Optional[Dict[str, Any]]) -> Dict[str, Any]: + """Copy headers; later sources and later entries in each dict win.""" + headers: Dict[str, Any] = {} + for source in sources: + for name, value in (source or {}).items(): + cls._set_header(headers, name, value) + return headers _default = None @@ -283,10 +276,9 @@ def param_serialize( config = self.configuration # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) + header_params = self._merge_headers(header_params, self.default_headers) if self.cookie: - header_params['Cookie'] = self.cookie + self._set_header(header_params, 'Cookie', self.cookie) if header_params: header_params = self.sanitize_for_serialization(header_params) header_params = dict( @@ -627,6 +619,13 @@ def parameters_to_tuples(self, params, collection_formats): new_params.append((k, v)) return new_params + def explode_query_object(self, name, obj): + """form style, explode: one query parameter per entry, keyed by the property name; a list repeats the name, None is left out""" + obj = self.sanitize_for_serialization(obj) + if not isinstance(obj, dict): + obj = {name: obj} + return [(k, item) for k, v in obj.items() for item in (v if isinstance(v, (list, tuple)) else [v]) if item is not None] + def parameters_to_url_query(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -645,11 +644,12 @@ def parameters_to_url_query(self, params, collection_formats): if isinstance(v, dict): v = json.dumps(v) - if k in collection_formats: + # a collection format applies only to a list; an exploded entry may share a declared array parameter's name + if k in collection_formats and isinstance(v, (list, tuple)): collection_format = collection_formats[k] if collection_format == 'multi': new_params.extend( - (k, quote(str(value).lower() if isinstance(value, bool) else str(value))) + (quote(str(k)), quote(str(value).lower() if isinstance(value, bool) else str(value))) for value in v ) else: @@ -662,12 +662,13 @@ def parameters_to_url_query(self, params, collection_formats): else: # csv is the default delimiter = ',' new_params.append( - (k, delimiter.join( + (quote(str(k)), delimiter.join( quote(str(value).lower() if isinstance(value, bool) else str(value)) for value in v)) ) else: - new_params.append((k, quote(str(v)))) + # names are quoted too: an exploded object's names are runtime data + new_params.append((quote(str(k)), quote(str(v)))) return "&".join(["=".join(map(str, item)) for item in new_params]) @@ -803,7 +804,11 @@ def _apply_auth_params( :param auth_setting: auth settings for the endpoint """ if auth_setting['in'] == 'cookie': - if not 'Cookie' in headers: + for key in list(headers): + if key.lower() == 'cookie': + self._set_header(headers, 'Cookie', headers[key]) + break + if not headers.get('Cookie'): headers['Cookie'] = "" else: headers['Cookie'] += "; " @@ -812,7 +817,7 @@ def _apply_auth_params( headers['Cookie'] += f"{auth_setting['key']}={cookie_value}" elif auth_setting['in'] == 'header': if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] + self._set_header(headers, auth_setting['key'], auth_setting['value']) elif auth_setting['in'] == 'query': queries.append((auth_setting['key'], auth_setting['value'])) else: diff --git a/kubernetes/client/models/admissionregistration_v1_service_reference.py b/kubernetes/client/models/admissionregistration_v1_service_reference.py index 4b30f06016..62b00d4172 100644 --- a/kubernetes/client/models/admissionregistration_v1_service_reference.py +++ b/kubernetes/client/models/admissionregistration_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AdmissionregistrationV1ServiceReference(BaseModel): diff --git a/kubernetes/client/models/admissionregistration_v1_webhook_client_config.py b/kubernetes/client/models/admissionregistration_v1_webhook_client_config.py index a23feffced..e361550c4b 100644 --- a/kubernetes/client/models/admissionregistration_v1_webhook_client_config.py +++ b/kubernetes/client/models/admissionregistration_v1_webhook_client_config.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AdmissionregistrationV1WebhookClientConfig(BaseModel): diff --git a/kubernetes/client/models/apiextensions_v1_service_reference.py b/kubernetes/client/models/apiextensions_v1_service_reference.py index 3cc2a02744..80990dbabb 100644 --- a/kubernetes/client/models/apiextensions_v1_service_reference.py +++ b/kubernetes/client/models/apiextensions_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiextensionsV1ServiceReference(BaseModel): diff --git a/kubernetes/client/models/apiextensions_v1_webhook_client_config.py b/kubernetes/client/models/apiextensions_v1_webhook_client_config.py index 420a6b56e0..1e8459a501 100644 --- a/kubernetes/client/models/apiextensions_v1_webhook_client_config.py +++ b/kubernetes/client/models/apiextensions_v1_webhook_client_config.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiextensionsV1WebhookClientConfig(BaseModel): diff --git a/kubernetes/client/models/apiregistration_v1_service_reference.py b/kubernetes/client/models/apiregistration_v1_service_reference.py index 79c245b8d2..06ee5b751f 100644 --- a/kubernetes/client/models/apiregistration_v1_service_reference.py +++ b/kubernetes/client/models/apiregistration_v1_service_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ApiregistrationV1ServiceReference(BaseModel): diff --git a/kubernetes/client/models/authentication_v1_token_request.py b/kubernetes/client/models/authentication_v1_token_request.py index 3b4ad744be..358ee74d38 100644 --- a/kubernetes/client/models/authentication_v1_token_request.py +++ b/kubernetes/client/models/authentication_v1_token_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class AuthenticationV1TokenRequest(BaseModel): diff --git a/kubernetes/client/models/core_v1_endpoint_port.py b/kubernetes/client/models/core_v1_endpoint_port.py index ae46003e98..da76c37ae6 100644 --- a/kubernetes/client/models/core_v1_endpoint_port.py +++ b/kubernetes/client/models/core_v1_endpoint_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EndpointPort(BaseModel): diff --git a/kubernetes/client/models/core_v1_event.py b/kubernetes/client/models/core_v1_event.py index 770f13baf1..82dc8096ee 100644 --- a/kubernetes/client/models/core_v1_event.py +++ b/kubernetes/client/models/core_v1_event.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1Event(BaseModel): diff --git a/kubernetes/client/models/core_v1_event_list.py b/kubernetes/client/models/core_v1_event_list.py index 7379fb72e3..8378186769 100644 --- a/kubernetes/client/models/core_v1_event_list.py +++ b/kubernetes/client/models/core_v1_event_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EventList(BaseModel): diff --git a/kubernetes/client/models/core_v1_event_series.py b/kubernetes/client/models/core_v1_event_series.py index 1ecb329601..befb987bf3 100644 --- a/kubernetes/client/models/core_v1_event_series.py +++ b/kubernetes/client/models/core_v1_event_series.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1EventSeries(BaseModel): diff --git a/kubernetes/client/models/core_v1_resource_claim.py b/kubernetes/client/models/core_v1_resource_claim.py index a8e4da433a..878d3eb307 100644 --- a/kubernetes/client/models/core_v1_resource_claim.py +++ b/kubernetes/client/models/core_v1_resource_claim.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class CoreV1ResourceClaim(BaseModel): diff --git a/kubernetes/client/models/discovery_v1_endpoint_port.py b/kubernetes/client/models/discovery_v1_endpoint_port.py index 3e0d5c1289..8e09fe0857 100644 --- a/kubernetes/client/models/discovery_v1_endpoint_port.py +++ b/kubernetes/client/models/discovery_v1_endpoint_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class DiscoveryV1EndpointPort(BaseModel): diff --git a/kubernetes/client/models/events_v1_event.py b/kubernetes/client/models/events_v1_event.py index d0c4242aa9..2ce37b9d0e 100644 --- a/kubernetes/client/models/events_v1_event.py +++ b/kubernetes/client/models/events_v1_event.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1Event(BaseModel): diff --git a/kubernetes/client/models/events_v1_event_list.py b/kubernetes/client/models/events_v1_event_list.py index 647a229165..0380f26b5e 100644 --- a/kubernetes/client/models/events_v1_event_list.py +++ b/kubernetes/client/models/events_v1_event_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1EventList(BaseModel): diff --git a/kubernetes/client/models/events_v1_event_series.py b/kubernetes/client/models/events_v1_event_series.py index 9729193dae..35b5536e58 100644 --- a/kubernetes/client/models/events_v1_event_series.py +++ b/kubernetes/client/models/events_v1_event_series.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class EventsV1EventSeries(BaseModel): diff --git a/kubernetes/client/models/flowcontrol_v1_subject.py b/kubernetes/client/models/flowcontrol_v1_subject.py index ec4b674b9b..f588100368 100644 --- a/kubernetes/client/models/flowcontrol_v1_subject.py +++ b/kubernetes/client/models/flowcontrol_v1_subject.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class FlowcontrolV1Subject(BaseModel): diff --git a/kubernetes/client/models/rbac_v1_subject.py b/kubernetes/client/models/rbac_v1_subject.py index 8d8b926534..f55a5e08df 100644 --- a/kubernetes/client/models/rbac_v1_subject.py +++ b/kubernetes/client/models/rbac_v1_subject.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class RbacV1Subject(BaseModel): diff --git a/kubernetes/client/models/resource_v1_resource_claim.py b/kubernetes/client/models/resource_v1_resource_claim.py index 78dec0a4e5..7a06bf2a21 100644 --- a/kubernetes/client/models/resource_v1_resource_claim.py +++ b/kubernetes/client/models/resource_v1_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class ResourceV1ResourceClaim(BaseModel): diff --git a/kubernetes/client/models/storage_v1_token_request.py b/kubernetes/client/models/storage_v1_token_request.py index 52ba475d18..c26590cb26 100644 --- a/kubernetes/client/models/storage_v1_token_request.py +++ b/kubernetes/client/models/storage_v1_token_request.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class StorageV1TokenRequest(BaseModel): diff --git a/kubernetes/client/models/v1_affinity.py b/kubernetes/client/models/v1_affinity.py index f688d27850..bea0bf1db3 100644 --- a/kubernetes/client/models/v1_affinity.py +++ b/kubernetes/client/models/v1_affinity.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Affinity(BaseModel): diff --git a/kubernetes/client/models/v1_aggregation_rule.py b/kubernetes/client/models/v1_aggregation_rule.py index 0a6d80d584..d04984e70c 100644 --- a/kubernetes/client/models/v1_aggregation_rule.py +++ b/kubernetes/client/models/v1_aggregation_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AggregationRule(BaseModel): diff --git a/kubernetes/client/models/v1_allocated_device_status.py b/kubernetes/client/models/v1_allocated_device_status.py index 23121ed751..e67953e9b8 100644 --- a/kubernetes/client/models/v1_allocated_device_status.py +++ b/kubernetes/client/models/v1_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/client/models/v1_allocation_result.py b/kubernetes/client/models/v1_allocation_result.py index 8c8ac3da33..1ab124dfdf 100644 --- a/kubernetes/client/models/v1_allocation_result.py +++ b/kubernetes/client/models/v1_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1_api_group.py b/kubernetes/client/models/v1_api_group.py index b9480748b4..38720d1a35 100644 --- a/kubernetes/client/models/v1_api_group.py +++ b/kubernetes/client/models/v1_api_group.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIGroup(BaseModel): diff --git a/kubernetes/client/models/v1_api_group_list.py b/kubernetes/client/models/v1_api_group_list.py index 98f9d338c7..bf08b388a9 100644 --- a/kubernetes/client/models/v1_api_group_list.py +++ b/kubernetes/client/models/v1_api_group_list.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIGroupList(BaseModel): diff --git a/kubernetes/client/models/v1_api_resource.py b/kubernetes/client/models/v1_api_resource.py index b6ef4cb5f8..f45350b591 100644 --- a/kubernetes/client/models/v1_api_resource.py +++ b/kubernetes/client/models/v1_api_resource.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIResource(BaseModel): diff --git a/kubernetes/client/models/v1_api_resource_list.py b/kubernetes/client/models/v1_api_resource_list.py index 7987b82d81..2d4736b10c 100644 --- a/kubernetes/client/models/v1_api_resource_list.py +++ b/kubernetes/client/models/v1_api_resource_list.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIResourceList(BaseModel): diff --git a/kubernetes/client/models/v1_api_service.py b/kubernetes/client/models/v1_api_service.py index 2e0da6d48d..a141254721 100644 --- a/kubernetes/client/models/v1_api_service.py +++ b/kubernetes/client/models/v1_api_service.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIService(BaseModel): diff --git a/kubernetes/client/models/v1_api_service_condition.py b/kubernetes/client/models/v1_api_service_condition.py index 9169194fca..0ee3f27979 100644 --- a/kubernetes/client/models/v1_api_service_condition.py +++ b/kubernetes/client/models/v1_api_service_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceCondition(BaseModel): diff --git a/kubernetes/client/models/v1_api_service_list.py b/kubernetes/client/models/v1_api_service_list.py index 83c5a61690..881e458855 100644 --- a/kubernetes/client/models/v1_api_service_list.py +++ b/kubernetes/client/models/v1_api_service_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceList(BaseModel): diff --git a/kubernetes/client/models/v1_api_service_spec.py b/kubernetes/client/models/v1_api_service_spec.py index 573bd62aaf..112364bac7 100644 --- a/kubernetes/client/models/v1_api_service_spec.py +++ b/kubernetes/client/models/v1_api_service_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceSpec(BaseModel): diff --git a/kubernetes/client/models/v1_api_service_status.py b/kubernetes/client/models/v1_api_service_status.py index 6452410f7b..08fefff821 100644 --- a/kubernetes/client/models/v1_api_service_status.py +++ b/kubernetes/client/models/v1_api_service_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIServiceStatus(BaseModel): diff --git a/kubernetes/client/models/v1_api_versions.py b/kubernetes/client/models/v1_api_versions.py index 6d9452cc0d..d023645131 100644 --- a/kubernetes/client/models/v1_api_versions.py +++ b/kubernetes/client/models/v1_api_versions.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1APIVersions(BaseModel): diff --git a/kubernetes/client/models/v1_app_armor_profile.py b/kubernetes/client/models/v1_app_armor_profile.py index 118f94888d..b9bd0e5ceb 100644 --- a/kubernetes/client/models/v1_app_armor_profile.py +++ b/kubernetes/client/models/v1_app_armor_profile.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AppArmorProfile(BaseModel): diff --git a/kubernetes/client/models/v1_apply_configuration.py b/kubernetes/client/models/v1_apply_configuration.py index 512523d03b..94ba3f8b9f 100644 --- a/kubernetes/client/models/v1_apply_configuration.py +++ b/kubernetes/client/models/v1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ApplyConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_attached_volume.py b/kubernetes/client/models/v1_attached_volume.py index 9b1fe439c9..42de8c33c8 100644 --- a/kubernetes/client/models/v1_attached_volume.py +++ b/kubernetes/client/models/v1_attached_volume.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AttachedVolume(BaseModel): diff --git a/kubernetes/client/models/v1_audit_annotation.py b/kubernetes/client/models/v1_audit_annotation.py index 4e13a379d8..b33ba7da56 100644 --- a/kubernetes/client/models/v1_audit_annotation.py +++ b/kubernetes/client/models/v1_audit_annotation.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AuditAnnotation(BaseModel): diff --git a/kubernetes/client/models/v1_aws_elastic_block_store_volume_source.py b/kubernetes/client/models/v1_aws_elastic_block_store_volume_source.py index 79e08298c6..4edb152415 100644 --- a/kubernetes/client/models/v1_aws_elastic_block_store_volume_source.py +++ b/kubernetes/client/models/v1_aws_elastic_block_store_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AWSElasticBlockStoreVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_azure_disk_volume_source.py b/kubernetes/client/models/v1_azure_disk_volume_source.py index 9f0c225664..4b68c30106 100644 --- a/kubernetes/client/models/v1_azure_disk_volume_source.py +++ b/kubernetes/client/models/v1_azure_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureDiskVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_azure_file_persistent_volume_source.py b/kubernetes/client/models/v1_azure_file_persistent_volume_source.py index d63bb3533c..ec902e5f5a 100644 --- a/kubernetes/client/models/v1_azure_file_persistent_volume_source.py +++ b/kubernetes/client/models/v1_azure_file_persistent_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureFilePersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_azure_file_volume_source.py b/kubernetes/client/models/v1_azure_file_volume_source.py index 1a8751f35a..b7652b527b 100644 --- a/kubernetes/client/models/v1_azure_file_volume_source.py +++ b/kubernetes/client/models/v1_azure_file_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1AzureFileVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_binding.py b/kubernetes/client/models/v1_binding.py index f1aa6d2fbf..eb452d6c4f 100644 --- a/kubernetes/client/models/v1_binding.py +++ b/kubernetes/client/models/v1_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Binding(BaseModel): diff --git a/kubernetes/client/models/v1_bound_object_reference.py b/kubernetes/client/models/v1_bound_object_reference.py index 19abddcedf..243a43ba24 100644 --- a/kubernetes/client/models/v1_bound_object_reference.py +++ b/kubernetes/client/models/v1_bound_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1BoundObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_capabilities.py b/kubernetes/client/models/v1_capabilities.py index 372859a289..2e2be985a7 100644 --- a/kubernetes/client/models/v1_capabilities.py +++ b/kubernetes/client/models/v1_capabilities.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Capabilities(BaseModel): diff --git a/kubernetes/client/models/v1_capacity_request_policy.py b/kubernetes/client/models/v1_capacity_request_policy.py index f832973fe5..5a9ef814e9 100644 --- a/kubernetes/client/models/v1_capacity_request_policy.py +++ b/kubernetes/client/models/v1_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_capacity_request_policy_range.py b/kubernetes/client/models/v1_capacity_request_policy_range.py index ee412d1616..03b2cb56a8 100644 --- a/kubernetes/client/models/v1_capacity_request_policy_range.py +++ b/kubernetes/client/models/v1_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/client/models/v1_capacity_requirements.py b/kubernetes/client/models/v1_capacity_requirements.py index 2938de0926..61f7aa1f1b 100644 --- a/kubernetes/client/models/v1_capacity_requirements.py +++ b/kubernetes/client/models/v1_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CapacityRequirements(BaseModel): diff --git a/kubernetes/client/models/v1_cel_device_selector.py b/kubernetes/client/models/v1_cel_device_selector.py index 92b1d68e09..8354c354da 100644 --- a/kubernetes/client/models/v1_cel_device_selector.py +++ b/kubernetes/client/models/v1_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CELDeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1_ceph_fs_persistent_volume_source.py b/kubernetes/client/models/v1_ceph_fs_persistent_volume_source.py index 742fa5c969..1476397c8e 100644 --- a/kubernetes/client/models/v1_ceph_fs_persistent_volume_source.py +++ b/kubernetes/client/models/v1_ceph_fs_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CephFSPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_ceph_fs_volume_source.py b/kubernetes/client/models/v1_ceph_fs_volume_source.py index 0de84a1695..b4e6bdf9e5 100644 --- a/kubernetes/client/models/v1_ceph_fs_volume_source.py +++ b/kubernetes/client/models/v1_ceph_fs_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CephFSVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_certificate_signing_request.py b/kubernetes/client/models/v1_certificate_signing_request.py index 850fbf94b6..e4adb64b87 100644 --- a/kubernetes/client/models/v1_certificate_signing_request.py +++ b/kubernetes/client/models/v1_certificate_signing_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequest(BaseModel): diff --git a/kubernetes/client/models/v1_certificate_signing_request_condition.py b/kubernetes/client/models/v1_certificate_signing_request_condition.py index ae946a1a10..c680ca0152 100644 --- a/kubernetes/client/models/v1_certificate_signing_request_condition.py +++ b/kubernetes/client/models/v1_certificate_signing_request_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestCondition(BaseModel): diff --git a/kubernetes/client/models/v1_certificate_signing_request_list.py b/kubernetes/client/models/v1_certificate_signing_request_list.py index 5231920f87..29329aa69e 100644 --- a/kubernetes/client/models/v1_certificate_signing_request_list.py +++ b/kubernetes/client/models/v1_certificate_signing_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestList(BaseModel): diff --git a/kubernetes/client/models/v1_certificate_signing_request_spec.py b/kubernetes/client/models/v1_certificate_signing_request_spec.py index 586f687bf8..6e28f17c70 100644 --- a/kubernetes/client/models/v1_certificate_signing_request_spec.py +++ b/kubernetes/client/models/v1_certificate_signing_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1_certificate_signing_request_status.py b/kubernetes/client/models/v1_certificate_signing_request_status.py index 773bdf86d0..007a2513cf 100644 --- a/kubernetes/client/models/v1_certificate_signing_request_status.py +++ b/kubernetes/client/models/v1_certificate_signing_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CertificateSigningRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1_cinder_persistent_volume_source.py b/kubernetes/client/models/v1_cinder_persistent_volume_source.py index ebbe24c26d..fef873824a 100644 --- a/kubernetes/client/models/v1_cinder_persistent_volume_source.py +++ b/kubernetes/client/models/v1_cinder_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CinderPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_cinder_volume_source.py b/kubernetes/client/models/v1_cinder_volume_source.py index d2fdc758fd..2eb7c5c1d5 100644 --- a/kubernetes/client/models/v1_cinder_volume_source.py +++ b/kubernetes/client/models/v1_cinder_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CinderVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_client_ip_config.py b/kubernetes/client/models/v1_client_ip_config.py index 1879bd4851..ad7083fc0b 100644 --- a/kubernetes/client/models/v1_client_ip_config.py +++ b/kubernetes/client/models/v1_client_ip_config.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClientIPConfig(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_role.py b/kubernetes/client/models/v1_cluster_role.py index 8cbbad2536..bf1d87640d 100644 --- a/kubernetes/client/models/v1_cluster_role.py +++ b/kubernetes/client/models/v1_cluster_role.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRole(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_role_binding.py b/kubernetes/client/models/v1_cluster_role_binding.py index 0c0bc4f5cf..5bc1503b2b 100644 --- a/kubernetes/client/models/v1_cluster_role_binding.py +++ b/kubernetes/client/models/v1_cluster_role_binding.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleBinding(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_role_binding_list.py b/kubernetes/client/models/v1_cluster_role_binding_list.py index 3d8cf0cf61..7089e45306 100644 --- a/kubernetes/client/models/v1_cluster_role_binding_list.py +++ b/kubernetes/client/models/v1_cluster_role_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleBindingList(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_role_list.py b/kubernetes/client/models/v1_cluster_role_list.py index 78e5438c78..e33cc19597 100644 --- a/kubernetes/client/models/v1_cluster_role_list.py +++ b/kubernetes/client/models/v1_cluster_role_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterRoleList(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_trust_bundle.py b/kubernetes/client/models/v1_cluster_trust_bundle.py index c7ffbc210f..5726ae0233 100644 --- a/kubernetes/client/models/v1_cluster_trust_bundle.py +++ b/kubernetes/client/models/v1_cluster_trust_bundle.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundle(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_trust_bundle_list.py b/kubernetes/client/models/v1_cluster_trust_bundle_list.py index 96d6e2af47..b3e4275202 100644 --- a/kubernetes/client/models/v1_cluster_trust_bundle_list.py +++ b/kubernetes/client/models/v1_cluster_trust_bundle_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleList(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_trust_bundle_projection.py b/kubernetes/client/models/v1_cluster_trust_bundle_projection.py index 3ac6fb2e08..0136580e92 100644 --- a/kubernetes/client/models/v1_cluster_trust_bundle_projection.py +++ b/kubernetes/client/models/v1_cluster_trust_bundle_projection.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleProjection(BaseModel): diff --git a/kubernetes/client/models/v1_cluster_trust_bundle_spec.py b/kubernetes/client/models/v1_cluster_trust_bundle_spec.py index 542aca5004..320d656056 100644 --- a/kubernetes/client/models/v1_cluster_trust_bundle_spec.py +++ b/kubernetes/client/models/v1_cluster_trust_bundle_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ClusterTrustBundleSpec(BaseModel): diff --git a/kubernetes/client/models/v1_component_condition.py b/kubernetes/client/models/v1_component_condition.py index f5c70b92e3..cc0bd3cdf8 100644 --- a/kubernetes/client/models/v1_component_condition.py +++ b/kubernetes/client/models/v1_component_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentCondition(BaseModel): diff --git a/kubernetes/client/models/v1_component_status.py b/kubernetes/client/models/v1_component_status.py index 0f6ad17445..b037eec0db 100644 --- a/kubernetes/client/models/v1_component_status.py +++ b/kubernetes/client/models/v1_component_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentStatus(BaseModel): diff --git a/kubernetes/client/models/v1_component_status_list.py b/kubernetes/client/models/v1_component_status_list.py index 7b66cb6f6b..bbaad27336 100644 --- a/kubernetes/client/models/v1_component_status_list.py +++ b/kubernetes/client/models/v1_component_status_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ComponentStatusList(BaseModel): diff --git a/kubernetes/client/models/v1_condition.py b/kubernetes/client/models/v1_condition.py index 4960daaf92..4fc017c94e 100644 --- a/kubernetes/client/models/v1_condition.py +++ b/kubernetes/client/models/v1_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Condition(BaseModel): diff --git a/kubernetes/client/models/v1_config_map.py b/kubernetes/client/models/v1_config_map.py index 89d22a91fa..dfb1458365 100644 --- a/kubernetes/client/models/v1_config_map.py +++ b/kubernetes/client/models/v1_config_map.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMap(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_env_source.py b/kubernetes/client/models/v1_config_map_env_source.py index 85f7a607a3..effaf08112 100644 --- a/kubernetes/client/models/v1_config_map_env_source.py +++ b/kubernetes/client/models/v1_config_map_env_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapEnvSource(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_key_selector.py b/kubernetes/client/models/v1_config_map_key_selector.py index d2d5d7f347..d911c196b4 100644 --- a/kubernetes/client/models/v1_config_map_key_selector.py +++ b/kubernetes/client/models/v1_config_map_key_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapKeySelector(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_list.py b/kubernetes/client/models/v1_config_map_list.py index ea4f65e2f8..f20d0418f7 100644 --- a/kubernetes/client/models/v1_config_map_list.py +++ b/kubernetes/client/models/v1_config_map_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapList(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_node_config_source.py b/kubernetes/client/models/v1_config_map_node_config_source.py index 161a326492..2e3d9fd80a 100644 --- a/kubernetes/client/models/v1_config_map_node_config_source.py +++ b/kubernetes/client/models/v1_config_map_node_config_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapNodeConfigSource(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_projection.py b/kubernetes/client/models/v1_config_map_projection.py index ad2ca81aef..214dec5b30 100644 --- a/kubernetes/client/models/v1_config_map_projection.py +++ b/kubernetes/client/models/v1_config_map_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapProjection(BaseModel): diff --git a/kubernetes/client/models/v1_config_map_volume_source.py b/kubernetes/client/models/v1_config_map_volume_source.py index 3a2cf63e7d..e1cdcab765 100644 --- a/kubernetes/client/models/v1_config_map_volume_source.py +++ b/kubernetes/client/models/v1_config_map_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ConfigMapVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_container.py b/kubernetes/client/models/v1_container.py index 52e40a8ad0..213039ea69 100644 --- a/kubernetes/client/models/v1_container.py +++ b/kubernetes/client/models/v1_container.py @@ -36,72 +36,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Container(BaseModel): diff --git a/kubernetes/client/models/v1_container_extended_resource_request.py b/kubernetes/client/models/v1_container_extended_resource_request.py index e427d9b7c7..7e67948553 100644 --- a/kubernetes/client/models/v1_container_extended_resource_request.py +++ b/kubernetes/client/models/v1_container_extended_resource_request.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerExtendedResourceRequest(BaseModel): diff --git a/kubernetes/client/models/v1_container_image.py b/kubernetes/client/models/v1_container_image.py index bce4c50740..eefdef4a95 100644 --- a/kubernetes/client/models/v1_container_image.py +++ b/kubernetes/client/models/v1_container_image.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerImage(BaseModel): diff --git a/kubernetes/client/models/v1_container_port.py b/kubernetes/client/models/v1_container_port.py index f2585af183..a7ce8676c2 100644 --- a/kubernetes/client/models/v1_container_port.py +++ b/kubernetes/client/models/v1_container_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerPort(BaseModel): diff --git a/kubernetes/client/models/v1_container_resize_policy.py b/kubernetes/client/models/v1_container_resize_policy.py index 4322243648..57644a94c1 100644 --- a/kubernetes/client/models/v1_container_resize_policy.py +++ b/kubernetes/client/models/v1_container_resize_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerResizePolicy(BaseModel): diff --git a/kubernetes/client/models/v1_container_restart_rule.py b/kubernetes/client/models/v1_container_restart_rule.py index 5ce11b48af..237ef33908 100644 --- a/kubernetes/client/models/v1_container_restart_rule.py +++ b/kubernetes/client/models/v1_container_restart_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerRestartRule(BaseModel): diff --git a/kubernetes/client/models/v1_container_restart_rule_on_exit_codes.py b/kubernetes/client/models/v1_container_restart_rule_on_exit_codes.py index f3556501c5..66c2f04131 100644 --- a/kubernetes/client/models/v1_container_restart_rule_on_exit_codes.py +++ b/kubernetes/client/models/v1_container_restart_rule_on_exit_codes.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerRestartRuleOnExitCodes(BaseModel): diff --git a/kubernetes/client/models/v1_container_state.py b/kubernetes/client/models/v1_container_state.py index aab299d019..b01bf13e85 100644 --- a/kubernetes/client/models/v1_container_state.py +++ b/kubernetes/client/models/v1_container_state.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerState(BaseModel): diff --git a/kubernetes/client/models/v1_container_state_running.py b/kubernetes/client/models/v1_container_state_running.py index b4632eb940..f1884169df 100644 --- a/kubernetes/client/models/v1_container_state_running.py +++ b/kubernetes/client/models/v1_container_state_running.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateRunning(BaseModel): diff --git a/kubernetes/client/models/v1_container_state_terminated.py b/kubernetes/client/models/v1_container_state_terminated.py index 9f3e0141e6..1d56a161a2 100644 --- a/kubernetes/client/models/v1_container_state_terminated.py +++ b/kubernetes/client/models/v1_container_state_terminated.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateTerminated(BaseModel): diff --git a/kubernetes/client/models/v1_container_state_waiting.py b/kubernetes/client/models/v1_container_state_waiting.py index f6c6428a0a..47227874bb 100644 --- a/kubernetes/client/models/v1_container_state_waiting.py +++ b/kubernetes/client/models/v1_container_state_waiting.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStateWaiting(BaseModel): diff --git a/kubernetes/client/models/v1_container_status.py b/kubernetes/client/models/v1_container_status.py index b48743001a..6d98310108 100644 --- a/kubernetes/client/models/v1_container_status.py +++ b/kubernetes/client/models/v1_container_status.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerStatus(BaseModel): diff --git a/kubernetes/client/models/v1_container_user.py b/kubernetes/client/models/v1_container_user.py index a21888cae2..00d6fc5250 100644 --- a/kubernetes/client/models/v1_container_user.py +++ b/kubernetes/client/models/v1_container_user.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ContainerUser(BaseModel): diff --git a/kubernetes/client/models/v1_controller_revision.py b/kubernetes/client/models/v1_controller_revision.py index ca0c507d73..3f9cc46cfe 100644 --- a/kubernetes/client/models/v1_controller_revision.py +++ b/kubernetes/client/models/v1_controller_revision.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ControllerRevision(BaseModel): diff --git a/kubernetes/client/models/v1_controller_revision_list.py b/kubernetes/client/models/v1_controller_revision_list.py index 7d8be62fa5..dd79fe6e49 100644 --- a/kubernetes/client/models/v1_controller_revision_list.py +++ b/kubernetes/client/models/v1_controller_revision_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ControllerRevisionList(BaseModel): diff --git a/kubernetes/client/models/v1_counter.py b/kubernetes/client/models/v1_counter.py index e5b245bcb4..072d303084 100644 --- a/kubernetes/client/models/v1_counter.py +++ b/kubernetes/client/models/v1_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Counter(BaseModel): diff --git a/kubernetes/client/models/v1_counter_set.py b/kubernetes/client/models/v1_counter_set.py index ab7795d7a7..c6daca4ded 100644 --- a/kubernetes/client/models/v1_counter_set.py +++ b/kubernetes/client/models/v1_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CounterSet(BaseModel): diff --git a/kubernetes/client/models/v1_cron_job.py b/kubernetes/client/models/v1_cron_job.py index 438cbab02c..5a6487bdb7 100644 --- a/kubernetes/client/models/v1_cron_job.py +++ b/kubernetes/client/models/v1_cron_job.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJob(BaseModel): diff --git a/kubernetes/client/models/v1_cron_job_list.py b/kubernetes/client/models/v1_cron_job_list.py index 7c5f92b9fc..03acb7d7e7 100644 --- a/kubernetes/client/models/v1_cron_job_list.py +++ b/kubernetes/client/models/v1_cron_job_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobList(BaseModel): diff --git a/kubernetes/client/models/v1_cron_job_spec.py b/kubernetes/client/models/v1_cron_job_spec.py index 481619529f..ea8bf8975a 100644 --- a/kubernetes/client/models/v1_cron_job_spec.py +++ b/kubernetes/client/models/v1_cron_job_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobSpec(BaseModel): diff --git a/kubernetes/client/models/v1_cron_job_status.py b/kubernetes/client/models/v1_cron_job_status.py index be22e9e008..9cae4b7d82 100644 --- a/kubernetes/client/models/v1_cron_job_status.py +++ b/kubernetes/client/models/v1_cron_job_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CronJobStatus(BaseModel): diff --git a/kubernetes/client/models/v1_cross_version_object_reference.py b/kubernetes/client/models/v1_cross_version_object_reference.py index 3977330a74..27527ef361 100644 --- a/kubernetes/client/models/v1_cross_version_object_reference.py +++ b/kubernetes/client/models/v1_cross_version_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CrossVersionObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_csi_driver.py b/kubernetes/client/models/v1_csi_driver.py index eaa1d32525..4c0f4caea7 100644 --- a/kubernetes/client/models/v1_csi_driver.py +++ b/kubernetes/client/models/v1_csi_driver.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriver(BaseModel): diff --git a/kubernetes/client/models/v1_csi_driver_list.py b/kubernetes/client/models/v1_csi_driver_list.py index fc39b3a030..97d287f824 100644 --- a/kubernetes/client/models/v1_csi_driver_list.py +++ b/kubernetes/client/models/v1_csi_driver_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriverList(BaseModel): diff --git a/kubernetes/client/models/v1_csi_driver_spec.py b/kubernetes/client/models/v1_csi_driver_spec.py index 9e0145b783..4aabd67180 100644 --- a/kubernetes/client/models/v1_csi_driver_spec.py +++ b/kubernetes/client/models/v1_csi_driver_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIDriverSpec(BaseModel): diff --git a/kubernetes/client/models/v1_csi_node.py b/kubernetes/client/models/v1_csi_node.py index f172fea64d..0e21fdb9cc 100644 --- a/kubernetes/client/models/v1_csi_node.py +++ b/kubernetes/client/models/v1_csi_node.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINode(BaseModel): diff --git a/kubernetes/client/models/v1_csi_node_driver.py b/kubernetes/client/models/v1_csi_node_driver.py index 0cdae4631d..abb2b21a05 100644 --- a/kubernetes/client/models/v1_csi_node_driver.py +++ b/kubernetes/client/models/v1_csi_node_driver.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeDriver(BaseModel): diff --git a/kubernetes/client/models/v1_csi_node_list.py b/kubernetes/client/models/v1_csi_node_list.py index 8a1ad68298..6a05d384bc 100644 --- a/kubernetes/client/models/v1_csi_node_list.py +++ b/kubernetes/client/models/v1_csi_node_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeList(BaseModel): diff --git a/kubernetes/client/models/v1_csi_node_spec.py b/kubernetes/client/models/v1_csi_node_spec.py index c51bbb6ffb..f9dea7b2cc 100644 --- a/kubernetes/client/models/v1_csi_node_spec.py +++ b/kubernetes/client/models/v1_csi_node_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeSpec(BaseModel): diff --git a/kubernetes/client/models/v1_csi_node_status.py b/kubernetes/client/models/v1_csi_node_status.py index 43831930a4..c00755e021 100644 --- a/kubernetes/client/models/v1_csi_node_status.py +++ b/kubernetes/client/models/v1_csi_node_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSINodeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_csi_persistent_volume_source.py b/kubernetes/client/models/v1_csi_persistent_volume_source.py index b7ee916304..eadf0186b8 100644 --- a/kubernetes/client/models/v1_csi_persistent_volume_source.py +++ b/kubernetes/client/models/v1_csi_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_csi_storage_capacity.py b/kubernetes/client/models/v1_csi_storage_capacity.py index 3760949647..956edfc302 100644 --- a/kubernetes/client/models/v1_csi_storage_capacity.py +++ b/kubernetes/client/models/v1_csi_storage_capacity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIStorageCapacity(BaseModel): diff --git a/kubernetes/client/models/v1_csi_storage_capacity_list.py b/kubernetes/client/models/v1_csi_storage_capacity_list.py index 0b2f705d27..f2eb02793f 100644 --- a/kubernetes/client/models/v1_csi_storage_capacity_list.py +++ b/kubernetes/client/models/v1_csi_storage_capacity_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIStorageCapacityList(BaseModel): diff --git a/kubernetes/client/models/v1_csi_volume_source.py b/kubernetes/client/models/v1_csi_volume_source.py index c3a9592bf6..1cfcbf77b8 100644 --- a/kubernetes/client/models/v1_csi_volume_source.py +++ b/kubernetes/client/models/v1_csi_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CSIVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_column_definition.py b/kubernetes/client/models/v1_custom_resource_column_definition.py index 31a5c8e66d..51d234eb67 100644 --- a/kubernetes/client/models/v1_custom_resource_column_definition.py +++ b/kubernetes/client/models/v1_custom_resource_column_definition.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceColumnDefinition(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_conversion.py b/kubernetes/client/models/v1_custom_resource_conversion.py index 96afb96938..84015a2160 100644 --- a/kubernetes/client/models/v1_custom_resource_conversion.py +++ b/kubernetes/client/models/v1_custom_resource_conversion.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceConversion(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition.py b/kubernetes/client/models/v1_custom_resource_definition.py index ab39f9d1a6..546e49838a 100644 --- a/kubernetes/client/models/v1_custom_resource_definition.py +++ b/kubernetes/client/models/v1_custom_resource_definition.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinition(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_condition.py b/kubernetes/client/models/v1_custom_resource_definition_condition.py index 0f84718ee5..d4d77e459b 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_condition.py +++ b/kubernetes/client/models/v1_custom_resource_definition_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionCondition(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_list.py b/kubernetes/client/models/v1_custom_resource_definition_list.py index bef02b9904..fedf9f8592 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_list.py +++ b/kubernetes/client/models/v1_custom_resource_definition_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionList(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_names.py b/kubernetes/client/models/v1_custom_resource_definition_names.py index 9ec73f6233..62be863f49 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_names.py +++ b/kubernetes/client/models/v1_custom_resource_definition_names.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionNames(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_spec.py b/kubernetes/client/models/v1_custom_resource_definition_spec.py index 5fc722c74a..f0c88f4d0d 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_spec.py +++ b/kubernetes/client/models/v1_custom_resource_definition_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionSpec(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_status.py b/kubernetes/client/models/v1_custom_resource_definition_status.py index 866805932b..426de8d657 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_status.py +++ b/kubernetes/client/models/v1_custom_resource_definition_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionStatus(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_definition_version.py b/kubernetes/client/models/v1_custom_resource_definition_version.py index 96c565d494..9f22711a60 100644 --- a/kubernetes/client/models/v1_custom_resource_definition_version.py +++ b/kubernetes/client/models/v1_custom_resource_definition_version.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceDefinitionVersion(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_subresource_scale.py b/kubernetes/client/models/v1_custom_resource_subresource_scale.py index a6c0e1fea8..63ac05ec24 100644 --- a/kubernetes/client/models/v1_custom_resource_subresource_scale.py +++ b/kubernetes/client/models/v1_custom_resource_subresource_scale.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceSubresourceScale(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_subresources.py b/kubernetes/client/models/v1_custom_resource_subresources.py index c9a48c2879..50bf59fcfb 100644 --- a/kubernetes/client/models/v1_custom_resource_subresources.py +++ b/kubernetes/client/models/v1_custom_resource_subresources.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceSubresources(BaseModel): diff --git a/kubernetes/client/models/v1_custom_resource_validation.py b/kubernetes/client/models/v1_custom_resource_validation.py index 63ebefbe55..2905aaf73f 100644 --- a/kubernetes/client/models/v1_custom_resource_validation.py +++ b/kubernetes/client/models/v1_custom_resource_validation.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1CustomResourceValidation(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_endpoint.py b/kubernetes/client/models/v1_daemon_endpoint.py index e99ce7dd38..102e04ccf2 100644 --- a/kubernetes/client/models/v1_daemon_endpoint.py +++ b/kubernetes/client/models/v1_daemon_endpoint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonEndpoint(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set.py b/kubernetes/client/models/v1_daemon_set.py index f55b329f97..05a6fd3950 100644 --- a/kubernetes/client/models/v1_daemon_set.py +++ b/kubernetes/client/models/v1_daemon_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSet(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set_condition.py b/kubernetes/client/models/v1_daemon_set_condition.py index 3c68a8a691..22701a8800 100644 --- a/kubernetes/client/models/v1_daemon_set_condition.py +++ b/kubernetes/client/models/v1_daemon_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetCondition(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set_list.py b/kubernetes/client/models/v1_daemon_set_list.py index 4101050084..bc07eb42df 100644 --- a/kubernetes/client/models/v1_daemon_set_list.py +++ b/kubernetes/client/models/v1_daemon_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetList(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set_spec.py b/kubernetes/client/models/v1_daemon_set_spec.py index e4c6b6c464..e04163b207 100644 --- a/kubernetes/client/models/v1_daemon_set_spec.py +++ b/kubernetes/client/models/v1_daemon_set_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetSpec(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set_status.py b/kubernetes/client/models/v1_daemon_set_status.py index 2afb0786cc..be45f44331 100644 --- a/kubernetes/client/models/v1_daemon_set_status.py +++ b/kubernetes/client/models/v1_daemon_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetStatus(BaseModel): diff --git a/kubernetes/client/models/v1_daemon_set_update_strategy.py b/kubernetes/client/models/v1_daemon_set_update_strategy.py index fa4fb3c113..7dcf269217 100644 --- a/kubernetes/client/models/v1_daemon_set_update_strategy.py +++ b/kubernetes/client/models/v1_daemon_set_update_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DaemonSetUpdateStrategy(BaseModel): diff --git a/kubernetes/client/models/v1_delete_options.py b/kubernetes/client/models/v1_delete_options.py index ea5949b2a5..5db8b6d41e 100644 --- a/kubernetes/client/models/v1_delete_options.py +++ b/kubernetes/client/models/v1_delete_options.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeleteOptions(BaseModel): diff --git a/kubernetes/client/models/v1_deployment.py b/kubernetes/client/models/v1_deployment.py index e0a3cee7d0..14fd2c0233 100644 --- a/kubernetes/client/models/v1_deployment.py +++ b/kubernetes/client/models/v1_deployment.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Deployment(BaseModel): diff --git a/kubernetes/client/models/v1_deployment_condition.py b/kubernetes/client/models/v1_deployment_condition.py index 6e3a80ea3c..39354f1019 100644 --- a/kubernetes/client/models/v1_deployment_condition.py +++ b/kubernetes/client/models/v1_deployment_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentCondition(BaseModel): diff --git a/kubernetes/client/models/v1_deployment_list.py b/kubernetes/client/models/v1_deployment_list.py index e172781fc0..c77e193eb7 100644 --- a/kubernetes/client/models/v1_deployment_list.py +++ b/kubernetes/client/models/v1_deployment_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentList(BaseModel): diff --git a/kubernetes/client/models/v1_deployment_spec.py b/kubernetes/client/models/v1_deployment_spec.py index 0c1a7e250b..a21cb2a315 100644 --- a/kubernetes/client/models/v1_deployment_spec.py +++ b/kubernetes/client/models/v1_deployment_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentSpec(BaseModel): diff --git a/kubernetes/client/models/v1_deployment_status.py b/kubernetes/client/models/v1_deployment_status.py index 284a2d43ec..ceceddb806 100644 --- a/kubernetes/client/models/v1_deployment_status.py +++ b/kubernetes/client/models/v1_deployment_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentStatus(BaseModel): diff --git a/kubernetes/client/models/v1_deployment_strategy.py b/kubernetes/client/models/v1_deployment_strategy.py index 0886b6202e..a6a3767a72 100644 --- a/kubernetes/client/models/v1_deployment_strategy.py +++ b/kubernetes/client/models/v1_deployment_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeploymentStrategy(BaseModel): diff --git a/kubernetes/client/models/v1_device.py b/kubernetes/client/models/v1_device.py index 7da6f503d2..73fc9b5844 100644 --- a/kubernetes/client/models/v1_device.py +++ b/kubernetes/client/models/v1_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Device(BaseModel): diff --git a/kubernetes/client/models/v1_device_allocation_configuration.py b/kubernetes/client/models/v1_device_allocation_configuration.py index 73ac82e694..94d3223c5b 100644 --- a/kubernetes/client/models/v1_device_allocation_configuration.py +++ b/kubernetes/client/models/v1_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_device_allocation_result.py b/kubernetes/client/models/v1_device_allocation_result.py index 03e8b1f80e..8329af0c4a 100644 --- a/kubernetes/client/models/v1_device_allocation_result.py +++ b/kubernetes/client/models/v1_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1_device_attribute.py b/kubernetes/client/models/v1_device_attribute.py index 61e5fc669c..d0ff21652e 100644 --- a/kubernetes/client/models/v1_device_attribute.py +++ b/kubernetes/client/models/v1_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceAttribute(BaseModel): diff --git a/kubernetes/client/models/v1_device_capacity.py b/kubernetes/client/models/v1_device_capacity.py index db7bdd363e..970e17ed3e 100644 --- a/kubernetes/client/models/v1_device_capacity.py +++ b/kubernetes/client/models/v1_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceCapacity(BaseModel): diff --git a/kubernetes/client/models/v1_device_claim.py b/kubernetes/client/models/v1_device_claim.py index 6dcb29f15e..507c6c7458 100644 --- a/kubernetes/client/models/v1_device_claim.py +++ b/kubernetes/client/models/v1_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClaim(BaseModel): diff --git a/kubernetes/client/models/v1_device_claim_configuration.py b/kubernetes/client/models/v1_device_claim_configuration.py index 52d1894be8..15b0a2a919 100644 --- a/kubernetes/client/models/v1_device_claim_configuration.py +++ b/kubernetes/client/models/v1_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_device_class.py b/kubernetes/client/models/v1_device_class.py index 3b00e3fcce..6830b13362 100644 --- a/kubernetes/client/models/v1_device_class.py +++ b/kubernetes/client/models/v1_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClass(BaseModel): diff --git a/kubernetes/client/models/v1_device_class_configuration.py b/kubernetes/client/models/v1_device_class_configuration.py index 14d3daae3c..fb397757c0 100644 --- a/kubernetes/client/models/v1_device_class_configuration.py +++ b/kubernetes/client/models/v1_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_device_class_list.py b/kubernetes/client/models/v1_device_class_list.py index 26e0201a8b..1a48382765 100644 --- a/kubernetes/client/models/v1_device_class_list.py +++ b/kubernetes/client/models/v1_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassList(BaseModel): diff --git a/kubernetes/client/models/v1_device_class_spec.py b/kubernetes/client/models/v1_device_class_spec.py index c169a8cc6d..a5422e6ab0 100644 --- a/kubernetes/client/models/v1_device_class_spec.py +++ b/kubernetes/client/models/v1_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceClassSpec(BaseModel): diff --git a/kubernetes/client/models/v1_device_constraint.py b/kubernetes/client/models/v1_device_constraint.py index c21dcf4725..3b74008182 100644 --- a/kubernetes/client/models/v1_device_constraint.py +++ b/kubernetes/client/models/v1_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceConstraint(BaseModel): diff --git a/kubernetes/client/models/v1_device_counter_consumption.py b/kubernetes/client/models/v1_device_counter_consumption.py index cbe59d7f57..6585465780 100644 --- a/kubernetes/client/models/v1_device_counter_consumption.py +++ b/kubernetes/client/models/v1_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/client/models/v1_device_derived_attribute.py b/kubernetes/client/models/v1_device_derived_attribute.py index 46309113d9..4e8cc86892 100644 --- a/kubernetes/client/models/v1_device_derived_attribute.py +++ b/kubernetes/client/models/v1_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/client/models/v1_device_request.py b/kubernetes/client/models/v1_device_request.py index b6f4c65635..658325ff4c 100644 --- a/kubernetes/client/models/v1_device_request.py +++ b/kubernetes/client/models/v1_device_request.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceRequest(BaseModel): diff --git a/kubernetes/client/models/v1_device_request_allocation_result.py b/kubernetes/client/models/v1_device_request_allocation_result.py index 4adc50bbb9..21a5fcc883 100644 --- a/kubernetes/client/models/v1_device_request_allocation_result.py +++ b/kubernetes/client/models/v1_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1_device_selector.py b/kubernetes/client/models/v1_device_selector.py index 90c0c6567b..e5f273eefb 100644 --- a/kubernetes/client/models/v1_device_selector.py +++ b/kubernetes/client/models/v1_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1_device_sub_request.py b/kubernetes/client/models/v1_device_sub_request.py index 1203488b23..c4049114df 100644 --- a/kubernetes/client/models/v1_device_sub_request.py +++ b/kubernetes/client/models/v1_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceSubRequest(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint.py b/kubernetes/client/models/v1_device_taint.py index 954c9e529e..d73e11fdae 100644 --- a/kubernetes/client/models/v1_device_taint.py +++ b/kubernetes/client/models/v1_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaint(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint_rule.py b/kubernetes/client/models/v1_device_taint_rule.py index 3facd5e016..357476248a 100644 --- a/kubernetes/client/models/v1_device_taint_rule.py +++ b/kubernetes/client/models/v1_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRule(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint_rule_list.py b/kubernetes/client/models/v1_device_taint_rule_list.py index baec33a64c..ffe3157e28 100644 --- a/kubernetes/client/models/v1_device_taint_rule_list.py +++ b/kubernetes/client/models/v1_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint_rule_spec.py b/kubernetes/client/models/v1_device_taint_rule_spec.py index 47776d20f0..5e84ef4db5 100644 --- a/kubernetes/client/models/v1_device_taint_rule_spec.py +++ b/kubernetes/client/models/v1_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint_rule_status.py b/kubernetes/client/models/v1_device_taint_rule_status.py index fff24d7c8a..2ae4805e42 100644 --- a/kubernetes/client/models/v1_device_taint_rule_status.py +++ b/kubernetes/client/models/v1_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/client/models/v1_device_taint_selector.py b/kubernetes/client/models/v1_device_taint_selector.py index 76b62e2fa9..0b47dead35 100644 --- a/kubernetes/client/models/v1_device_taint_selector.py +++ b/kubernetes/client/models/v1_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceTaintSelector(BaseModel): diff --git a/kubernetes/client/models/v1_device_toleration.py b/kubernetes/client/models/v1_device_toleration.py index 407c1110f3..359b9a641e 100644 --- a/kubernetes/client/models/v1_device_toleration.py +++ b/kubernetes/client/models/v1_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DeviceToleration(BaseModel): diff --git a/kubernetes/client/models/v1_downward_api_projection.py b/kubernetes/client/models/v1_downward_api_projection.py index 01b68562fe..3e57debcb3 100644 --- a/kubernetes/client/models/v1_downward_api_projection.py +++ b/kubernetes/client/models/v1_downward_api_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIProjection(BaseModel): diff --git a/kubernetes/client/models/v1_downward_api_volume_file.py b/kubernetes/client/models/v1_downward_api_volume_file.py index 8a7334f2ee..cca68c3307 100644 --- a/kubernetes/client/models/v1_downward_api_volume_file.py +++ b/kubernetes/client/models/v1_downward_api_volume_file.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIVolumeFile(BaseModel): diff --git a/kubernetes/client/models/v1_downward_api_volume_source.py b/kubernetes/client/models/v1_downward_api_volume_source.py index d131433ae4..66ca947f0f 100644 --- a/kubernetes/client/models/v1_downward_api_volume_source.py +++ b/kubernetes/client/models/v1_downward_api_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1DownwardAPIVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_empty_dir_volume_source.py b/kubernetes/client/models/v1_empty_dir_volume_source.py index 4f6174455f..9ab31bd3cf 100644 --- a/kubernetes/client/models/v1_empty_dir_volume_source.py +++ b/kubernetes/client/models/v1_empty_dir_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EmptyDirVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint.py b/kubernetes/client/models/v1_endpoint.py index 09739ba841..9a2e0c4c43 100644 --- a/kubernetes/client/models/v1_endpoint.py +++ b/kubernetes/client/models/v1_endpoint.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Endpoint(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_address.py b/kubernetes/client/models/v1_endpoint_address.py index d502addf64..c189752107 100644 --- a/kubernetes/client/models/v1_endpoint_address.py +++ b/kubernetes/client/models/v1_endpoint_address.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointAddress(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_conditions.py b/kubernetes/client/models/v1_endpoint_conditions.py index 9bc83ef75e..9f5e20e894 100644 --- a/kubernetes/client/models/v1_endpoint_conditions.py +++ b/kubernetes/client/models/v1_endpoint_conditions.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointConditions(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_hints.py b/kubernetes/client/models/v1_endpoint_hints.py index 56a830a11e..6882ada033 100644 --- a/kubernetes/client/models/v1_endpoint_hints.py +++ b/kubernetes/client/models/v1_endpoint_hints.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointHints(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_slice.py b/kubernetes/client/models/v1_endpoint_slice.py index a6465187c9..46102b820b 100644 --- a/kubernetes/client/models/v1_endpoint_slice.py +++ b/kubernetes/client/models/v1_endpoint_slice.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSlice(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_slice_list.py b/kubernetes/client/models/v1_endpoint_slice_list.py index b0bc2d5406..eb2a908627 100644 --- a/kubernetes/client/models/v1_endpoint_slice_list.py +++ b/kubernetes/client/models/v1_endpoint_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSliceList(BaseModel): diff --git a/kubernetes/client/models/v1_endpoint_subset.py b/kubernetes/client/models/v1_endpoint_subset.py index 08b007bfbe..16af0f3e33 100644 --- a/kubernetes/client/models/v1_endpoint_subset.py +++ b/kubernetes/client/models/v1_endpoint_subset.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointSubset(BaseModel): diff --git a/kubernetes/client/models/v1_endpoints.py b/kubernetes/client/models/v1_endpoints.py index 93b3bafe7e..dcc5fe6d86 100644 --- a/kubernetes/client/models/v1_endpoints.py +++ b/kubernetes/client/models/v1_endpoints.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Endpoints(BaseModel): diff --git a/kubernetes/client/models/v1_endpoints_list.py b/kubernetes/client/models/v1_endpoints_list.py index 9196c36b64..c3241c4f68 100644 --- a/kubernetes/client/models/v1_endpoints_list.py +++ b/kubernetes/client/models/v1_endpoints_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EndpointsList(BaseModel): diff --git a/kubernetes/client/models/v1_env_from_source.py b/kubernetes/client/models/v1_env_from_source.py index 1898e1f3f7..9125295c93 100644 --- a/kubernetes/client/models/v1_env_from_source.py +++ b/kubernetes/client/models/v1_env_from_source.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvFromSource(BaseModel): diff --git a/kubernetes/client/models/v1_env_var.py b/kubernetes/client/models/v1_env_var.py index f9244b78af..2add346b23 100644 --- a/kubernetes/client/models/v1_env_var.py +++ b/kubernetes/client/models/v1_env_var.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvVar(BaseModel): diff --git a/kubernetes/client/models/v1_env_var_source.py b/kubernetes/client/models/v1_env_var_source.py index 21f907cb01..7ea13329b4 100644 --- a/kubernetes/client/models/v1_env_var_source.py +++ b/kubernetes/client/models/v1_env_var_source.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EnvVarSource(BaseModel): diff --git a/kubernetes/client/models/v1_ephemeral_container.py b/kubernetes/client/models/v1_ephemeral_container.py index 69ab1a42df..486a1a62e7 100644 --- a/kubernetes/client/models/v1_ephemeral_container.py +++ b/kubernetes/client/models/v1_ephemeral_container.py @@ -36,72 +36,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EphemeralContainer(BaseModel): diff --git a/kubernetes/client/models/v1_ephemeral_volume_source.py b/kubernetes/client/models/v1_ephemeral_volume_source.py index 708262012b..d17b462b22 100644 --- a/kubernetes/client/models/v1_ephemeral_volume_source.py +++ b/kubernetes/client/models/v1_ephemeral_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EphemeralVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_event_source.py b/kubernetes/client/models/v1_event_source.py index 3e0dc80211..54189208f1 100644 --- a/kubernetes/client/models/v1_event_source.py +++ b/kubernetes/client/models/v1_event_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EventSource(BaseModel): diff --git a/kubernetes/client/models/v1_eviction.py b/kubernetes/client/models/v1_eviction.py index 29df5891b0..f9cae1e0da 100644 --- a/kubernetes/client/models/v1_eviction.py +++ b/kubernetes/client/models/v1_eviction.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Eviction(BaseModel): diff --git a/kubernetes/client/models/v1_eviction_responder.py b/kubernetes/client/models/v1_eviction_responder.py index 884e0e9fc6..ecf5b13254 100644 --- a/kubernetes/client/models/v1_eviction_responder.py +++ b/kubernetes/client/models/v1_eviction_responder.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1EvictionResponder(BaseModel): diff --git a/kubernetes/client/models/v1_exact_device_request.py b/kubernetes/client/models/v1_exact_device_request.py index ce12b29f32..473c143da2 100644 --- a/kubernetes/client/models/v1_exact_device_request.py +++ b/kubernetes/client/models/v1_exact_device_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExactDeviceRequest(BaseModel): diff --git a/kubernetes/client/models/v1_exec_action.py b/kubernetes/client/models/v1_exec_action.py index 635de92310..5e40e618f8 100644 --- a/kubernetes/client/models/v1_exec_action.py +++ b/kubernetes/client/models/v1_exec_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExecAction(BaseModel): diff --git a/kubernetes/client/models/v1_exempt_priority_level_configuration.py b/kubernetes/client/models/v1_exempt_priority_level_configuration.py index 0b5a0d40a4..00f15c80dd 100644 --- a/kubernetes/client/models/v1_exempt_priority_level_configuration.py +++ b/kubernetes/client/models/v1_exempt_priority_level_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExemptPriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_expression_warning.py b/kubernetes/client/models/v1_expression_warning.py index eae58f9c7f..54b352c251 100644 --- a/kubernetes/client/models/v1_expression_warning.py +++ b/kubernetes/client/models/v1_expression_warning.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExpressionWarning(BaseModel): diff --git a/kubernetes/client/models/v1_external_documentation.py b/kubernetes/client/models/v1_external_documentation.py index 696ae28fe2..6bb86c37a7 100644 --- a/kubernetes/client/models/v1_external_documentation.py +++ b/kubernetes/client/models/v1_external_documentation.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ExternalDocumentation(BaseModel): diff --git a/kubernetes/client/models/v1_fc_volume_source.py b/kubernetes/client/models/v1_fc_volume_source.py index 5ecba4a217..b1a53def0a 100644 --- a/kubernetes/client/models/v1_fc_volume_source.py +++ b/kubernetes/client/models/v1_fc_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FCVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_field_selector_attributes.py b/kubernetes/client/models/v1_field_selector_attributes.py index 3052f57b88..a06ed215ae 100644 --- a/kubernetes/client/models/v1_field_selector_attributes.py +++ b/kubernetes/client/models/v1_field_selector_attributes.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FieldSelectorAttributes(BaseModel): diff --git a/kubernetes/client/models/v1_field_selector_requirement.py b/kubernetes/client/models/v1_field_selector_requirement.py index ce7d4d6df0..744b1ead31 100644 --- a/kubernetes/client/models/v1_field_selector_requirement.py +++ b/kubernetes/client/models/v1_field_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FieldSelectorRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_file_key_selector.py b/kubernetes/client/models/v1_file_key_selector.py index 617b44aa36..d76b16b65c 100644 --- a/kubernetes/client/models/v1_file_key_selector.py +++ b/kubernetes/client/models/v1_file_key_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FileKeySelector(BaseModel): diff --git a/kubernetes/client/models/v1_flex_persistent_volume_source.py b/kubernetes/client/models/v1_flex_persistent_volume_source.py index 16d92c760b..258e5ea466 100644 --- a/kubernetes/client/models/v1_flex_persistent_volume_source.py +++ b/kubernetes/client/models/v1_flex_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlexPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_flex_volume_source.py b/kubernetes/client/models/v1_flex_volume_source.py index f6478655b9..f14f307813 100644 --- a/kubernetes/client/models/v1_flex_volume_source.py +++ b/kubernetes/client/models/v1_flex_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlexVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_flocker_volume_source.py b/kubernetes/client/models/v1_flocker_volume_source.py index 582e7debdb..86e3961697 100644 --- a/kubernetes/client/models/v1_flocker_volume_source.py +++ b/kubernetes/client/models/v1_flocker_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlockerVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_flow_distinguisher_method.py b/kubernetes/client/models/v1_flow_distinguisher_method.py index 1a7b0efd3f..137c3b331c 100644 --- a/kubernetes/client/models/v1_flow_distinguisher_method.py +++ b/kubernetes/client/models/v1_flow_distinguisher_method.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowDistinguisherMethod(BaseModel): diff --git a/kubernetes/client/models/v1_flow_schema.py b/kubernetes/client/models/v1_flow_schema.py index 50de47027e..71a99fe456 100644 --- a/kubernetes/client/models/v1_flow_schema.py +++ b/kubernetes/client/models/v1_flow_schema.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchema(BaseModel): diff --git a/kubernetes/client/models/v1_flow_schema_condition.py b/kubernetes/client/models/v1_flow_schema_condition.py index 3792f41e95..524410db98 100644 --- a/kubernetes/client/models/v1_flow_schema_condition.py +++ b/kubernetes/client/models/v1_flow_schema_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaCondition(BaseModel): diff --git a/kubernetes/client/models/v1_flow_schema_list.py b/kubernetes/client/models/v1_flow_schema_list.py index af7d5a4429..01824a9dd4 100644 --- a/kubernetes/client/models/v1_flow_schema_list.py +++ b/kubernetes/client/models/v1_flow_schema_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaList(BaseModel): diff --git a/kubernetes/client/models/v1_flow_schema_spec.py b/kubernetes/client/models/v1_flow_schema_spec.py index 1cf27ff2b5..e4a73410f3 100644 --- a/kubernetes/client/models/v1_flow_schema_spec.py +++ b/kubernetes/client/models/v1_flow_schema_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaSpec(BaseModel): diff --git a/kubernetes/client/models/v1_flow_schema_status.py b/kubernetes/client/models/v1_flow_schema_status.py index 14519e58b0..713febfa76 100644 --- a/kubernetes/client/models/v1_flow_schema_status.py +++ b/kubernetes/client/models/v1_flow_schema_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1FlowSchemaStatus(BaseModel): diff --git a/kubernetes/client/models/v1_for_node.py b/kubernetes/client/models/v1_for_node.py index 90abc18c94..631843a673 100644 --- a/kubernetes/client/models/v1_for_node.py +++ b/kubernetes/client/models/v1_for_node.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ForNode(BaseModel): diff --git a/kubernetes/client/models/v1_for_zone.py b/kubernetes/client/models/v1_for_zone.py index 642f5d708c..7c667e067c 100644 --- a/kubernetes/client/models/v1_for_zone.py +++ b/kubernetes/client/models/v1_for_zone.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ForZone(BaseModel): diff --git a/kubernetes/client/models/v1_gce_persistent_disk_volume_source.py b/kubernetes/client/models/v1_gce_persistent_disk_volume_source.py index 797cb4518b..3a69f6f295 100644 --- a/kubernetes/client/models/v1_gce_persistent_disk_volume_source.py +++ b/kubernetes/client/models/v1_gce_persistent_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GCEPersistentDiskVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_git_repo_volume_source.py b/kubernetes/client/models/v1_git_repo_volume_source.py index 119e4a3e87..8e6a497805 100644 --- a/kubernetes/client/models/v1_git_repo_volume_source.py +++ b/kubernetes/client/models/v1_git_repo_volume_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GitRepoVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_glusterfs_persistent_volume_source.py b/kubernetes/client/models/v1_glusterfs_persistent_volume_source.py index 97b9ab1bc5..03e8194e61 100644 --- a/kubernetes/client/models/v1_glusterfs_persistent_volume_source.py +++ b/kubernetes/client/models/v1_glusterfs_persistent_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GlusterfsPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_glusterfs_volume_source.py b/kubernetes/client/models/v1_glusterfs_volume_source.py index e312638804..715d13638a 100644 --- a/kubernetes/client/models/v1_glusterfs_volume_source.py +++ b/kubernetes/client/models/v1_glusterfs_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GlusterfsVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_group_resource.py b/kubernetes/client/models/v1_group_resource.py index 05acb363f2..2abe788ce5 100644 --- a/kubernetes/client/models/v1_group_resource.py +++ b/kubernetes/client/models/v1_group_resource.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupResource(BaseModel): diff --git a/kubernetes/client/models/v1_group_subject.py b/kubernetes/client/models/v1_group_subject.py index c923962366..a69c5e04d2 100644 --- a/kubernetes/client/models/v1_group_subject.py +++ b/kubernetes/client/models/v1_group_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupSubject(BaseModel): diff --git a/kubernetes/client/models/v1_group_version_for_discovery.py b/kubernetes/client/models/v1_group_version_for_discovery.py index e1b1e0a8f9..b2a69170b1 100644 --- a/kubernetes/client/models/v1_group_version_for_discovery.py +++ b/kubernetes/client/models/v1_group_version_for_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupVersionForDiscovery(BaseModel): diff --git a/kubernetes/client/models/v1_group_version_kind.py b/kubernetes/client/models/v1_group_version_kind.py index e2b2bc337e..52490fbdf0 100644 --- a/kubernetes/client/models/v1_group_version_kind.py +++ b/kubernetes/client/models/v1_group_version_kind.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GroupVersionKind(BaseModel): diff --git a/kubernetes/client/models/v1_grpc_action.py b/kubernetes/client/models/v1_grpc_action.py index 2dd0bbb200..20821246eb 100644 --- a/kubernetes/client/models/v1_grpc_action.py +++ b/kubernetes/client/models/v1_grpc_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1GRPCAction(BaseModel): diff --git a/kubernetes/client/models/v1_horizontal_pod_autoscaler.py b/kubernetes/client/models/v1_horizontal_pod_autoscaler.py index 3a94d62b58..26e7331457 100644 --- a/kubernetes/client/models/v1_horizontal_pod_autoscaler.py +++ b/kubernetes/client/models/v1_horizontal_pod_autoscaler.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscaler(BaseModel): diff --git a/kubernetes/client/models/v1_horizontal_pod_autoscaler_list.py b/kubernetes/client/models/v1_horizontal_pod_autoscaler_list.py index 1f46049741..3c399ca615 100644 --- a/kubernetes/client/models/v1_horizontal_pod_autoscaler_list.py +++ b/kubernetes/client/models/v1_horizontal_pod_autoscaler_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerList(BaseModel): diff --git a/kubernetes/client/models/v1_horizontal_pod_autoscaler_spec.py b/kubernetes/client/models/v1_horizontal_pod_autoscaler_spec.py index 7b733c93e1..1e31e4fd97 100644 --- a/kubernetes/client/models/v1_horizontal_pod_autoscaler_spec.py +++ b/kubernetes/client/models/v1_horizontal_pod_autoscaler_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerSpec(BaseModel): diff --git a/kubernetes/client/models/v1_horizontal_pod_autoscaler_status.py b/kubernetes/client/models/v1_horizontal_pod_autoscaler_status.py index ffd3b66ff7..cb5fc2f4a2 100644 --- a/kubernetes/client/models/v1_horizontal_pod_autoscaler_status.py +++ b/kubernetes/client/models/v1_horizontal_pod_autoscaler_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HorizontalPodAutoscalerStatus(BaseModel): diff --git a/kubernetes/client/models/v1_host_alias.py b/kubernetes/client/models/v1_host_alias.py index 362ee5bb7b..ca5d5608b1 100644 --- a/kubernetes/client/models/v1_host_alias.py +++ b/kubernetes/client/models/v1_host_alias.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostAlias(BaseModel): diff --git a/kubernetes/client/models/v1_host_ip.py b/kubernetes/client/models/v1_host_ip.py index 0471339e19..61c8e7178a 100644 --- a/kubernetes/client/models/v1_host_ip.py +++ b/kubernetes/client/models/v1_host_ip.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostIP(BaseModel): diff --git a/kubernetes/client/models/v1_host_path_volume_source.py b/kubernetes/client/models/v1_host_path_volume_source.py index 6eb3682148..ff395d2846 100644 --- a/kubernetes/client/models/v1_host_path_volume_source.py +++ b/kubernetes/client/models/v1_host_path_volume_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HostPathVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_http_get_action.py b/kubernetes/client/models/v1_http_get_action.py index 647b22dde8..3584514e05 100644 --- a/kubernetes/client/models/v1_http_get_action.py +++ b/kubernetes/client/models/v1_http_get_action.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPGetAction(BaseModel): diff --git a/kubernetes/client/models/v1_http_header.py b/kubernetes/client/models/v1_http_header.py index 5e0bf37dfa..167d10e93a 100644 --- a/kubernetes/client/models/v1_http_header.py +++ b/kubernetes/client/models/v1_http_header.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPHeader(BaseModel): diff --git a/kubernetes/client/models/v1_http_ingress_path.py b/kubernetes/client/models/v1_http_ingress_path.py index b21ff663fd..b6cb7f0ac2 100644 --- a/kubernetes/client/models/v1_http_ingress_path.py +++ b/kubernetes/client/models/v1_http_ingress_path.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPIngressPath(BaseModel): diff --git a/kubernetes/client/models/v1_http_ingress_rule_value.py b/kubernetes/client/models/v1_http_ingress_rule_value.py index 586e502e1d..0692e8e5fa 100644 --- a/kubernetes/client/models/v1_http_ingress_rule_value.py +++ b/kubernetes/client/models/v1_http_ingress_rule_value.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1HTTPIngressRuleValue(BaseModel): diff --git a/kubernetes/client/models/v1_image_volume_source.py b/kubernetes/client/models/v1_image_volume_source.py index 870653ecd3..4810dc6c86 100644 --- a/kubernetes/client/models/v1_image_volume_source.py +++ b/kubernetes/client/models/v1_image_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ImageVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_image_volume_status.py b/kubernetes/client/models/v1_image_volume_status.py index 7dcf748450..2c1f134c9b 100644 --- a/kubernetes/client/models/v1_image_volume_status.py +++ b/kubernetes/client/models/v1_image_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ImageVolumeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_ingress.py b/kubernetes/client/models/v1_ingress.py index f708937772..7df9f8a563 100644 --- a/kubernetes/client/models/v1_ingress.py +++ b/kubernetes/client/models/v1_ingress.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Ingress(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_backend.py b/kubernetes/client/models/v1_ingress_backend.py index 8014298481..27ce118e90 100644 --- a/kubernetes/client/models/v1_ingress_backend.py +++ b/kubernetes/client/models/v1_ingress_backend.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressBackend(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_class.py b/kubernetes/client/models/v1_ingress_class.py index 7ba4049af2..b22865caa6 100644 --- a/kubernetes/client/models/v1_ingress_class.py +++ b/kubernetes/client/models/v1_ingress_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClass(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_class_list.py b/kubernetes/client/models/v1_ingress_class_list.py index 0e92e5869e..53e14165c7 100644 --- a/kubernetes/client/models/v1_ingress_class_list.py +++ b/kubernetes/client/models/v1_ingress_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassList(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_class_parameters_reference.py b/kubernetes/client/models/v1_ingress_class_parameters_reference.py index 0270a70f7e..a1239f3680 100644 --- a/kubernetes/client/models/v1_ingress_class_parameters_reference.py +++ b/kubernetes/client/models/v1_ingress_class_parameters_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassParametersReference(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_class_spec.py b/kubernetes/client/models/v1_ingress_class_spec.py index 8d8e647da4..6f153ad20c 100644 --- a/kubernetes/client/models/v1_ingress_class_spec.py +++ b/kubernetes/client/models/v1_ingress_class_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressClassSpec(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_list.py b/kubernetes/client/models/v1_ingress_list.py index c38ac66991..72fdc1f043 100644 --- a/kubernetes/client/models/v1_ingress_list.py +++ b/kubernetes/client/models/v1_ingress_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressList(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_load_balancer_ingress.py b/kubernetes/client/models/v1_ingress_load_balancer_ingress.py index 768b288d95..018756982d 100644 --- a/kubernetes/client/models/v1_ingress_load_balancer_ingress.py +++ b/kubernetes/client/models/v1_ingress_load_balancer_ingress.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressLoadBalancerIngress(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_load_balancer_status.py b/kubernetes/client/models/v1_ingress_load_balancer_status.py index 99ecd80d79..06b2ab463b 100644 --- a/kubernetes/client/models/v1_ingress_load_balancer_status.py +++ b/kubernetes/client/models/v1_ingress_load_balancer_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressLoadBalancerStatus(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_port_status.py b/kubernetes/client/models/v1_ingress_port_status.py index 141179d147..3651b531b6 100644 --- a/kubernetes/client/models/v1_ingress_port_status.py +++ b/kubernetes/client/models/v1_ingress_port_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressPortStatus(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_rule.py b/kubernetes/client/models/v1_ingress_rule.py index 62b1e2abb1..fb794ec49d 100644 --- a/kubernetes/client/models/v1_ingress_rule.py +++ b/kubernetes/client/models/v1_ingress_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressRule(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_service_backend.py b/kubernetes/client/models/v1_ingress_service_backend.py index 1552456b2d..d8ae0fa211 100644 --- a/kubernetes/client/models/v1_ingress_service_backend.py +++ b/kubernetes/client/models/v1_ingress_service_backend.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressServiceBackend(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_spec.py b/kubernetes/client/models/v1_ingress_spec.py index adc1db2e29..8a5bce6d11 100644 --- a/kubernetes/client/models/v1_ingress_spec.py +++ b/kubernetes/client/models/v1_ingress_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressSpec(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_status.py b/kubernetes/client/models/v1_ingress_status.py index 7b05afb17a..4f3f88c787 100644 --- a/kubernetes/client/models/v1_ingress_status.py +++ b/kubernetes/client/models/v1_ingress_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressStatus(BaseModel): diff --git a/kubernetes/client/models/v1_ingress_tls.py b/kubernetes/client/models/v1_ingress_tls.py index 7282cdee97..a99d50c6c1 100644 --- a/kubernetes/client/models/v1_ingress_tls.py +++ b/kubernetes/client/models/v1_ingress_tls.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IngressTLS(BaseModel): diff --git a/kubernetes/client/models/v1_ip_address.py b/kubernetes/client/models/v1_ip_address.py index 145e4e07db..02f88d8341 100644 --- a/kubernetes/client/models/v1_ip_address.py +++ b/kubernetes/client/models/v1_ip_address.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddress(BaseModel): diff --git a/kubernetes/client/models/v1_ip_address_list.py b/kubernetes/client/models/v1_ip_address_list.py index f4bca6a944..6add21f431 100644 --- a/kubernetes/client/models/v1_ip_address_list.py +++ b/kubernetes/client/models/v1_ip_address_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddressList(BaseModel): diff --git a/kubernetes/client/models/v1_ip_address_spec.py b/kubernetes/client/models/v1_ip_address_spec.py index 94d5d9f3c2..4576e59796 100644 --- a/kubernetes/client/models/v1_ip_address_spec.py +++ b/kubernetes/client/models/v1_ip_address_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPAddressSpec(BaseModel): diff --git a/kubernetes/client/models/v1_ip_block.py b/kubernetes/client/models/v1_ip_block.py index c203fda4d6..b178be3bb6 100644 --- a/kubernetes/client/models/v1_ip_block.py +++ b/kubernetes/client/models/v1_ip_block.py @@ -26,72 +26,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1IPBlock(BaseModel): diff --git a/kubernetes/client/models/v1_iscsi_persistent_volume_source.py b/kubernetes/client/models/v1_iscsi_persistent_volume_source.py index 0141172d8b..36819a93db 100644 --- a/kubernetes/client/models/v1_iscsi_persistent_volume_source.py +++ b/kubernetes/client/models/v1_iscsi_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ISCSIPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_iscsi_volume_source.py b/kubernetes/client/models/v1_iscsi_volume_source.py index 102d56a8ae..1a6d5a9079 100644 --- a/kubernetes/client/models/v1_iscsi_volume_source.py +++ b/kubernetes/client/models/v1_iscsi_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ISCSIVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_job.py b/kubernetes/client/models/v1_job.py index 327e1d1335..3fc7b73b37 100644 --- a/kubernetes/client/models/v1_job.py +++ b/kubernetes/client/models/v1_job.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Job(BaseModel): diff --git a/kubernetes/client/models/v1_job_condition.py b/kubernetes/client/models/v1_job_condition.py index ed8300c314..e3ed4f8c91 100644 --- a/kubernetes/client/models/v1_job_condition.py +++ b/kubernetes/client/models/v1_job_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobCondition(BaseModel): diff --git a/kubernetes/client/models/v1_job_list.py b/kubernetes/client/models/v1_job_list.py index 0695a2298a..fe36cd08da 100644 --- a/kubernetes/client/models/v1_job_list.py +++ b/kubernetes/client/models/v1_job_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobList(BaseModel): diff --git a/kubernetes/client/models/v1_job_scheduling_configuration.py b/kubernetes/client/models/v1_job_scheduling_configuration.py index ac6d0ac130..daf0203c1e 100644 --- a/kubernetes/client/models/v1_job_scheduling_configuration.py +++ b/kubernetes/client/models/v1_job_scheduling_configuration.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobSchedulingConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_job_spec.py b/kubernetes/client/models/v1_job_spec.py index 2278f7b5bc..5681c6be01 100644 --- a/kubernetes/client/models/v1_job_spec.py +++ b/kubernetes/client/models/v1_job_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobSpec(BaseModel): diff --git a/kubernetes/client/models/v1_job_status.py b/kubernetes/client/models/v1_job_status.py index c85737d321..2cd489a3f8 100644 --- a/kubernetes/client/models/v1_job_status.py +++ b/kubernetes/client/models/v1_job_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobStatus(BaseModel): diff --git a/kubernetes/client/models/v1_job_template_spec.py b/kubernetes/client/models/v1_job_template_spec.py index 93fdaa465f..8a55fe1a6d 100644 --- a/kubernetes/client/models/v1_job_template_spec.py +++ b/kubernetes/client/models/v1_job_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JobTemplateSpec(BaseModel): diff --git a/kubernetes/client/models/v1_json_patch.py b/kubernetes/client/models/v1_json_patch.py index 4926a82709..8dd5581662 100644 --- a/kubernetes/client/models/v1_json_patch.py +++ b/kubernetes/client/models/v1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JSONPatch(BaseModel): diff --git a/kubernetes/client/models/v1_json_schema_props.py b/kubernetes/client/models/v1_json_schema_props.py index ac4b2fb6d3..02a67bff06 100644 --- a/kubernetes/client/models/v1_json_schema_props.py +++ b/kubernetes/client/models/v1_json_schema_props.py @@ -28,72 +28,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1JSONSchemaProps(BaseModel): diff --git a/kubernetes/client/models/v1_key_to_path.py b/kubernetes/client/models/v1_key_to_path.py index 7caa268847..13f5203737 100644 --- a/kubernetes/client/models/v1_key_to_path.py +++ b/kubernetes/client/models/v1_key_to_path.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1KeyToPath(BaseModel): diff --git a/kubernetes/client/models/v1_label_selector.py b/kubernetes/client/models/v1_label_selector.py index f28b932446..d0b5c82658 100644 --- a/kubernetes/client/models/v1_label_selector.py +++ b/kubernetes/client/models/v1_label_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelector(BaseModel): diff --git a/kubernetes/client/models/v1_label_selector_attributes.py b/kubernetes/client/models/v1_label_selector_attributes.py index ee4774ca01..128498d357 100644 --- a/kubernetes/client/models/v1_label_selector_attributes.py +++ b/kubernetes/client/models/v1_label_selector_attributes.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelectorAttributes(BaseModel): diff --git a/kubernetes/client/models/v1_label_selector_requirement.py b/kubernetes/client/models/v1_label_selector_requirement.py index f34bc3b463..0c7ac74087 100644 --- a/kubernetes/client/models/v1_label_selector_requirement.py +++ b/kubernetes/client/models/v1_label_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LabelSelectorRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_lease.py b/kubernetes/client/models/v1_lease.py index 402014e088..fa77f0526d 100644 --- a/kubernetes/client/models/v1_lease.py +++ b/kubernetes/client/models/v1_lease.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Lease(BaseModel): diff --git a/kubernetes/client/models/v1_lease_list.py b/kubernetes/client/models/v1_lease_list.py index 782de582cc..48c3205f1c 100644 --- a/kubernetes/client/models/v1_lease_list.py +++ b/kubernetes/client/models/v1_lease_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LeaseList(BaseModel): diff --git a/kubernetes/client/models/v1_lease_spec.py b/kubernetes/client/models/v1_lease_spec.py index 4e23aafe4b..6d209d8a9f 100644 --- a/kubernetes/client/models/v1_lease_spec.py +++ b/kubernetes/client/models/v1_lease_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LeaseSpec(BaseModel): diff --git a/kubernetes/client/models/v1_lifecycle.py b/kubernetes/client/models/v1_lifecycle.py index 0f12f7056a..eafa608b49 100644 --- a/kubernetes/client/models/v1_lifecycle.py +++ b/kubernetes/client/models/v1_lifecycle.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Lifecycle(BaseModel): diff --git a/kubernetes/client/models/v1_lifecycle_handler.py b/kubernetes/client/models/v1_lifecycle_handler.py index afec7c24f1..96b2125110 100644 --- a/kubernetes/client/models/v1_lifecycle_handler.py +++ b/kubernetes/client/models/v1_lifecycle_handler.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LifecycleHandler(BaseModel): diff --git a/kubernetes/client/models/v1_limit_range.py b/kubernetes/client/models/v1_limit_range.py index 44b323fed7..e0ad315ecc 100644 --- a/kubernetes/client/models/v1_limit_range.py +++ b/kubernetes/client/models/v1_limit_range.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRange(BaseModel): diff --git a/kubernetes/client/models/v1_limit_range_item.py b/kubernetes/client/models/v1_limit_range_item.py index 05f3fe45bb..9ddadc8214 100644 --- a/kubernetes/client/models/v1_limit_range_item.py +++ b/kubernetes/client/models/v1_limit_range_item.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeItem(BaseModel): diff --git a/kubernetes/client/models/v1_limit_range_list.py b/kubernetes/client/models/v1_limit_range_list.py index f6218c424a..969f5da535 100644 --- a/kubernetes/client/models/v1_limit_range_list.py +++ b/kubernetes/client/models/v1_limit_range_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeList(BaseModel): diff --git a/kubernetes/client/models/v1_limit_range_spec.py b/kubernetes/client/models/v1_limit_range_spec.py index c41916c589..1bcaa806ab 100644 --- a/kubernetes/client/models/v1_limit_range_spec.py +++ b/kubernetes/client/models/v1_limit_range_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitRangeSpec(BaseModel): diff --git a/kubernetes/client/models/v1_limit_response.py b/kubernetes/client/models/v1_limit_response.py index 0468581197..ff285c7a87 100644 --- a/kubernetes/client/models/v1_limit_response.py +++ b/kubernetes/client/models/v1_limit_response.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitResponse(BaseModel): diff --git a/kubernetes/client/models/v1_limited_priority_level_configuration.py b/kubernetes/client/models/v1_limited_priority_level_configuration.py index d8bdb1fdfe..d0fda1db23 100644 --- a/kubernetes/client/models/v1_limited_priority_level_configuration.py +++ b/kubernetes/client/models/v1_limited_priority_level_configuration.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LimitedPriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_linux_container_user.py b/kubernetes/client/models/v1_linux_container_user.py index e91e29517a..0612df37a1 100644 --- a/kubernetes/client/models/v1_linux_container_user.py +++ b/kubernetes/client/models/v1_linux_container_user.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LinuxContainerUser(BaseModel): diff --git a/kubernetes/client/models/v1_list_meta.py b/kubernetes/client/models/v1_list_meta.py index 80f36c0fe8..97eafd86eb 100644 --- a/kubernetes/client/models/v1_list_meta.py +++ b/kubernetes/client/models/v1_list_meta.py @@ -27,72 +27,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ListMeta(BaseModel): diff --git a/kubernetes/client/models/v1_load_balancer_ingress.py b/kubernetes/client/models/v1_load_balancer_ingress.py index 38d1280eb8..de0e7f4c66 100644 --- a/kubernetes/client/models/v1_load_balancer_ingress.py +++ b/kubernetes/client/models/v1_load_balancer_ingress.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LoadBalancerIngress(BaseModel): diff --git a/kubernetes/client/models/v1_load_balancer_status.py b/kubernetes/client/models/v1_load_balancer_status.py index 17aeb5770d..b56199bc9b 100644 --- a/kubernetes/client/models/v1_load_balancer_status.py +++ b/kubernetes/client/models/v1_load_balancer_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LoadBalancerStatus(BaseModel): diff --git a/kubernetes/client/models/v1_local_object_reference.py b/kubernetes/client/models/v1_local_object_reference.py index 3dae59c1c3..63d3fdf06d 100644 --- a/kubernetes/client/models/v1_local_object_reference.py +++ b/kubernetes/client/models/v1_local_object_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_local_subject_access_review.py b/kubernetes/client/models/v1_local_subject_access_review.py index 330f3cc6cf..6b4e3f01ba 100644 --- a/kubernetes/client/models/v1_local_subject_access_review.py +++ b/kubernetes/client/models/v1_local_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalSubjectAccessReview(BaseModel): diff --git a/kubernetes/client/models/v1_local_volume_source.py b/kubernetes/client/models/v1_local_volume_source.py index a7b6eb7eca..128c894eb5 100644 --- a/kubernetes/client/models/v1_local_volume_source.py +++ b/kubernetes/client/models/v1_local_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1LocalVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_managed_fields_entry.py b/kubernetes/client/models/v1_managed_fields_entry.py index 94ff5a8dfd..1822b60829 100644 --- a/kubernetes/client/models/v1_managed_fields_entry.py +++ b/kubernetes/client/models/v1_managed_fields_entry.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ManagedFieldsEntry(BaseModel): diff --git a/kubernetes/client/models/v1_match_condition.py b/kubernetes/client/models/v1_match_condition.py index 3b9494cfb0..c77470cf87 100644 --- a/kubernetes/client/models/v1_match_condition.py +++ b/kubernetes/client/models/v1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MatchCondition(BaseModel): diff --git a/kubernetes/client/models/v1_match_resources.py b/kubernetes/client/models/v1_match_resources.py index 0c141da1bd..2fa53a8fc2 100644 --- a/kubernetes/client/models/v1_match_resources.py +++ b/kubernetes/client/models/v1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MatchResources(BaseModel): diff --git a/kubernetes/client/models/v1_modify_volume_status.py b/kubernetes/client/models/v1_modify_volume_status.py index c2e6417c3d..96353db664 100644 --- a/kubernetes/client/models/v1_modify_volume_status.py +++ b/kubernetes/client/models/v1_modify_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ModifyVolumeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy.py b/kubernetes/client/models/v1_mutating_admission_policy.py index 5799baa584..1ea6ec446d 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy.py +++ b/kubernetes/client/models/v1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy_binding.py b/kubernetes/client/models/v1_mutating_admission_policy_binding.py index f49e429d23..0e44c39ff0 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy_binding.py +++ b/kubernetes/client/models/v1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy_binding_list.py b/kubernetes/client/models/v1_mutating_admission_policy_binding_list.py index 3f9c088de2..10156768ad 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy_binding_list.py +++ b/kubernetes/client/models/v1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy_binding_spec.py b/kubernetes/client/models/v1_mutating_admission_policy_binding_spec.py index b7ca151b5f..4eb7d81603 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/client/models/v1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy_list.py b/kubernetes/client/models/v1_mutating_admission_policy_list.py index 52cb1f9942..bbba468750 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy_list.py +++ b/kubernetes/client/models/v1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_admission_policy_spec.py b/kubernetes/client/models/v1_mutating_admission_policy_spec.py index 396c6c2ee8..13c68088bb 100644 --- a/kubernetes/client/models/v1_mutating_admission_policy_spec.py +++ b/kubernetes/client/models/v1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_webhook.py b/kubernetes/client/models/v1_mutating_webhook.py index 6a03629d2d..1686dad585 100644 --- a/kubernetes/client/models/v1_mutating_webhook.py +++ b/kubernetes/client/models/v1_mutating_webhook.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhook(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_webhook_configuration.py b/kubernetes/client/models/v1_mutating_webhook_configuration.py index 127827f049..1178a4a6e5 100644 --- a/kubernetes/client/models/v1_mutating_webhook_configuration.py +++ b/kubernetes/client/models/v1_mutating_webhook_configuration.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhookConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_mutating_webhook_configuration_list.py b/kubernetes/client/models/v1_mutating_webhook_configuration_list.py index 8e1daf38f7..671d384079 100644 --- a/kubernetes/client/models/v1_mutating_webhook_configuration_list.py +++ b/kubernetes/client/models/v1_mutating_webhook_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1MutatingWebhookConfigurationList(BaseModel): diff --git a/kubernetes/client/models/v1_mutation.py b/kubernetes/client/models/v1_mutation.py index 848e72a663..988dfcfbb6 100644 --- a/kubernetes/client/models/v1_mutation.py +++ b/kubernetes/client/models/v1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Mutation(BaseModel): diff --git a/kubernetes/client/models/v1_named_rule_with_operations.py b/kubernetes/client/models/v1_named_rule_with_operations.py index 961fbc5561..ddfc787276 100644 --- a/kubernetes/client/models/v1_named_rule_with_operations.py +++ b/kubernetes/client/models/v1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/client/models/v1_namespace.py b/kubernetes/client/models/v1_namespace.py index 7d98f5de6b..07cd46d472 100644 --- a/kubernetes/client/models/v1_namespace.py +++ b/kubernetes/client/models/v1_namespace.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Namespace(BaseModel): diff --git a/kubernetes/client/models/v1_namespace_condition.py b/kubernetes/client/models/v1_namespace_condition.py index 3e7e3910b6..bd30b6ad44 100644 --- a/kubernetes/client/models/v1_namespace_condition.py +++ b/kubernetes/client/models/v1_namespace_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceCondition(BaseModel): diff --git a/kubernetes/client/models/v1_namespace_list.py b/kubernetes/client/models/v1_namespace_list.py index 0f8e21e6db..1b8928de56 100644 --- a/kubernetes/client/models/v1_namespace_list.py +++ b/kubernetes/client/models/v1_namespace_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceList(BaseModel): diff --git a/kubernetes/client/models/v1_namespace_spec.py b/kubernetes/client/models/v1_namespace_spec.py index 40dbf609cd..0aa2d9e131 100644 --- a/kubernetes/client/models/v1_namespace_spec.py +++ b/kubernetes/client/models/v1_namespace_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceSpec(BaseModel): diff --git a/kubernetes/client/models/v1_namespace_status.py b/kubernetes/client/models/v1_namespace_status.py index dfbd5c3f0e..1acadc829d 100644 --- a/kubernetes/client/models/v1_namespace_status.py +++ b/kubernetes/client/models/v1_namespace_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NamespaceStatus(BaseModel): diff --git a/kubernetes/client/models/v1_network_device_data.py b/kubernetes/client/models/v1_network_device_data.py index 697b7c2c61..d6f53b8e08 100644 --- a/kubernetes/client/models/v1_network_device_data.py +++ b/kubernetes/client/models/v1_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkDeviceData(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy.py b/kubernetes/client/models/v1_network_policy.py index f1ef143604..fd23498e82 100644 --- a/kubernetes/client/models/v1_network_policy.py +++ b/kubernetes/client/models/v1_network_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_egress_rule.py b/kubernetes/client/models/v1_network_policy_egress_rule.py index 466cf7996c..c7c1b38453 100644 --- a/kubernetes/client/models/v1_network_policy_egress_rule.py +++ b/kubernetes/client/models/v1_network_policy_egress_rule.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyEgressRule(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_ingress_rule.py b/kubernetes/client/models/v1_network_policy_ingress_rule.py index 8aff36f15e..2ca77cd07b 100644 --- a/kubernetes/client/models/v1_network_policy_ingress_rule.py +++ b/kubernetes/client/models/v1_network_policy_ingress_rule.py @@ -28,72 +28,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyIngressRule(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_list.py b/kubernetes/client/models/v1_network_policy_list.py index 911e309554..bdaecdbaed 100644 --- a/kubernetes/client/models/v1_network_policy_list.py +++ b/kubernetes/client/models/v1_network_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyList(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_peer.py b/kubernetes/client/models/v1_network_policy_peer.py index 20e6e2a426..3958ec6e3e 100644 --- a/kubernetes/client/models/v1_network_policy_peer.py +++ b/kubernetes/client/models/v1_network_policy_peer.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyPeer(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_port.py b/kubernetes/client/models/v1_network_policy_port.py index 3aba96368d..baec8734e8 100644 --- a/kubernetes/client/models/v1_network_policy_port.py +++ b/kubernetes/client/models/v1_network_policy_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicyPort(BaseModel): diff --git a/kubernetes/client/models/v1_network_policy_spec.py b/kubernetes/client/models/v1_network_policy_spec.py index b8f7f4b4aa..016ab919b0 100644 --- a/kubernetes/client/models/v1_network_policy_spec.py +++ b/kubernetes/client/models/v1_network_policy_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NetworkPolicySpec(BaseModel): diff --git a/kubernetes/client/models/v1_nfs_volume_source.py b/kubernetes/client/models/v1_nfs_volume_source.py index d788ac6150..16a30468f7 100644 --- a/kubernetes/client/models/v1_nfs_volume_source.py +++ b/kubernetes/client/models/v1_nfs_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NFSVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_node.py b/kubernetes/client/models/v1_node.py index ba0ac676de..9eff0456ce 100644 --- a/kubernetes/client/models/v1_node.py +++ b/kubernetes/client/models/v1_node.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Node(BaseModel): diff --git a/kubernetes/client/models/v1_node_address.py b/kubernetes/client/models/v1_node_address.py index 80ee22be5b..062e9261c2 100644 --- a/kubernetes/client/models/v1_node_address.py +++ b/kubernetes/client/models/v1_node_address.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAddress(BaseModel): diff --git a/kubernetes/client/models/v1_node_affinity.py b/kubernetes/client/models/v1_node_affinity.py index 5b9598a79e..5fbd901edc 100644 --- a/kubernetes/client/models/v1_node_affinity.py +++ b/kubernetes/client/models/v1_node_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAffinity(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_mapped_resources.py b/kubernetes/client/models/v1_node_allocatable_mapped_resources.py index 3fd8739210..5dd2aabf80 100644 --- a/kubernetes/client/models/v1_node_allocatable_mapped_resources.py +++ b/kubernetes/client/models/v1_node_allocatable_mapped_resources.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableMappedResources(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_mapping.py b/kubernetes/client/models/v1_node_allocatable_mapping.py index ccb1f86ad3..389ba2f7b0 100644 --- a/kubernetes/client/models/v1_node_allocatable_mapping.py +++ b/kubernetes/client/models/v1_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_overhead.py b/kubernetes/client/models/v1_node_allocatable_overhead.py index cbb994195b..9e21fc3856 100644 --- a/kubernetes/client/models/v1_node_allocatable_overhead.py +++ b/kubernetes/client/models/v1_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_overhead_resources.py b/kubernetes/client/models/v1_node_allocatable_overhead_resources.py index aba85fbdee..549b5f15bd 100644 --- a/kubernetes/client/models/v1_node_allocatable_overhead_resources.py +++ b/kubernetes/client/models/v1_node_allocatable_overhead_resources.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableOverheadResources(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_resource.py b/kubernetes/client/models/v1_node_allocatable_resource.py index dd83f036e0..596ee79fb3 100644 --- a/kubernetes/client/models/v1_node_allocatable_resource.py +++ b/kubernetes/client/models/v1_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableResource(BaseModel): diff --git a/kubernetes/client/models/v1_node_allocatable_resource_claim_status.py b/kubernetes/client/models/v1_node_allocatable_resource_claim_status.py index a4391beafa..a2a72a4f50 100644 --- a/kubernetes/client/models/v1_node_allocatable_resource_claim_status.py +++ b/kubernetes/client/models/v1_node_allocatable_resource_claim_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeAllocatableResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1_node_condition.py b/kubernetes/client/models/v1_node_condition.py index d98f30181b..2b79fe4b42 100644 --- a/kubernetes/client/models/v1_node_condition.py +++ b/kubernetes/client/models/v1_node_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeCondition(BaseModel): diff --git a/kubernetes/client/models/v1_node_config_source.py b/kubernetes/client/models/v1_node_config_source.py index 0f333d655c..bfdd33882f 100644 --- a/kubernetes/client/models/v1_node_config_source.py +++ b/kubernetes/client/models/v1_node_config_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeConfigSource(BaseModel): diff --git a/kubernetes/client/models/v1_node_config_status.py b/kubernetes/client/models/v1_node_config_status.py index 76a3d94432..c29f98ff69 100644 --- a/kubernetes/client/models/v1_node_config_status.py +++ b/kubernetes/client/models/v1_node_config_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeConfigStatus(BaseModel): diff --git a/kubernetes/client/models/v1_node_daemon_endpoints.py b/kubernetes/client/models/v1_node_daemon_endpoints.py index 2ef57a5290..1e70e5ee6c 100644 --- a/kubernetes/client/models/v1_node_daemon_endpoints.py +++ b/kubernetes/client/models/v1_node_daemon_endpoints.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeDaemonEndpoints(BaseModel): diff --git a/kubernetes/client/models/v1_node_features.py b/kubernetes/client/models/v1_node_features.py index 7ad62bd8d3..4c3e512a80 100644 --- a/kubernetes/client/models/v1_node_features.py +++ b/kubernetes/client/models/v1_node_features.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeFeatures(BaseModel): diff --git a/kubernetes/client/models/v1_node_list.py b/kubernetes/client/models/v1_node_list.py index 36d6c19f4b..32b66e6435 100644 --- a/kubernetes/client/models/v1_node_list.py +++ b/kubernetes/client/models/v1_node_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeList(BaseModel): diff --git a/kubernetes/client/models/v1_node_pod_preemption_policy.py b/kubernetes/client/models/v1_node_pod_preemption_policy.py index 9dd5a8ae37..9303b5fcbe 100644 --- a/kubernetes/client/models/v1_node_pod_preemption_policy.py +++ b/kubernetes/client/models/v1_node_pod_preemption_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodePodPreemptionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_node_runtime_handler.py b/kubernetes/client/models/v1_node_runtime_handler.py index 43b39665eb..9f8b43cc04 100644 --- a/kubernetes/client/models/v1_node_runtime_handler.py +++ b/kubernetes/client/models/v1_node_runtime_handler.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeRuntimeHandler(BaseModel): diff --git a/kubernetes/client/models/v1_node_runtime_handler_features.py b/kubernetes/client/models/v1_node_runtime_handler_features.py index 666d5844a8..f0615325d3 100644 --- a/kubernetes/client/models/v1_node_runtime_handler_features.py +++ b/kubernetes/client/models/v1_node_runtime_handler_features.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeRuntimeHandlerFeatures(BaseModel): diff --git a/kubernetes/client/models/v1_node_selector.py b/kubernetes/client/models/v1_node_selector.py index a9fb8e0f1a..bedc392069 100644 --- a/kubernetes/client/models/v1_node_selector.py +++ b/kubernetes/client/models/v1_node_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelector(BaseModel): diff --git a/kubernetes/client/models/v1_node_selector_requirement.py b/kubernetes/client/models/v1_node_selector_requirement.py index 47844421ef..b28757e14c 100644 --- a/kubernetes/client/models/v1_node_selector_requirement.py +++ b/kubernetes/client/models/v1_node_selector_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelectorRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_node_selector_term.py b/kubernetes/client/models/v1_node_selector_term.py index 784e3f3838..f7b730c658 100644 --- a/kubernetes/client/models/v1_node_selector_term.py +++ b/kubernetes/client/models/v1_node_selector_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSelectorTerm(BaseModel): diff --git a/kubernetes/client/models/v1_node_spec.py b/kubernetes/client/models/v1_node_spec.py index 2eee7f709f..f80f269b61 100644 --- a/kubernetes/client/models/v1_node_spec.py +++ b/kubernetes/client/models/v1_node_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSpec(BaseModel): diff --git a/kubernetes/client/models/v1_node_status.py b/kubernetes/client/models/v1_node_status.py index f83060fb2b..af109e6957 100644 --- a/kubernetes/client/models/v1_node_status.py +++ b/kubernetes/client/models/v1_node_status.py @@ -34,72 +34,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_node_swap_status.py b/kubernetes/client/models/v1_node_swap_status.py index 5301d42d2d..f28e62fadf 100644 --- a/kubernetes/client/models/v1_node_swap_status.py +++ b/kubernetes/client/models/v1_node_swap_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSwapStatus(BaseModel): diff --git a/kubernetes/client/models/v1_node_system_info.py b/kubernetes/client/models/v1_node_system_info.py index 1cb81b21e3..1605f12392 100644 --- a/kubernetes/client/models/v1_node_system_info.py +++ b/kubernetes/client/models/v1_node_system_info.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NodeSystemInfo(BaseModel): diff --git a/kubernetes/client/models/v1_non_resource_attributes.py b/kubernetes/client/models/v1_non_resource_attributes.py index cdf351965f..6ed5b0c7ba 100644 --- a/kubernetes/client/models/v1_non_resource_attributes.py +++ b/kubernetes/client/models/v1_non_resource_attributes.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourceAttributes(BaseModel): diff --git a/kubernetes/client/models/v1_non_resource_policy_rule.py b/kubernetes/client/models/v1_non_resource_policy_rule.py index f243de1e32..d3d6e52062 100644 --- a/kubernetes/client/models/v1_non_resource_policy_rule.py +++ b/kubernetes/client/models/v1_non_resource_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourcePolicyRule(BaseModel): diff --git a/kubernetes/client/models/v1_non_resource_rule.py b/kubernetes/client/models/v1_non_resource_rule.py index c64996c99c..584299c8bb 100644 --- a/kubernetes/client/models/v1_non_resource_rule.py +++ b/kubernetes/client/models/v1_non_resource_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1NonResourceRule(BaseModel): diff --git a/kubernetes/client/models/v1_object_field_selector.py b/kubernetes/client/models/v1_object_field_selector.py index 143b0abb8d..2093bbc2b2 100644 --- a/kubernetes/client/models/v1_object_field_selector.py +++ b/kubernetes/client/models/v1_object_field_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectFieldSelector(BaseModel): diff --git a/kubernetes/client/models/v1_object_meta.py b/kubernetes/client/models/v1_object_meta.py index 513ee1cbef..751fd5ae3c 100644 --- a/kubernetes/client/models/v1_object_meta.py +++ b/kubernetes/client/models/v1_object_meta.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectMeta(BaseModel): diff --git a/kubernetes/client/models/v1_object_reference.py b/kubernetes/client/models/v1_object_reference.py index eab24cc2e4..08c9b53dd5 100644 --- a/kubernetes/client/models/v1_object_reference.py +++ b/kubernetes/client/models/v1_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_opaque_device_configuration.py b/kubernetes/client/models/v1_opaque_device_configuration.py index 365a082743..8f30d9c6ac 100644 --- a/kubernetes/client/models/v1_opaque_device_configuration.py +++ b/kubernetes/client/models/v1_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_overhead.py b/kubernetes/client/models/v1_overhead.py index 9e100d8584..c9099a0a94 100644 --- a/kubernetes/client/models/v1_overhead.py +++ b/kubernetes/client/models/v1_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Overhead(BaseModel): diff --git a/kubernetes/client/models/v1_owner_reference.py b/kubernetes/client/models/v1_owner_reference.py index 2c61aeafb6..f2eb3968f3 100644 --- a/kubernetes/client/models/v1_owner_reference.py +++ b/kubernetes/client/models/v1_owner_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1OwnerReference(BaseModel): diff --git a/kubernetes/client/models/v1_param_kind.py b/kubernetes/client/models/v1_param_kind.py index 32d555a6fd..7d588b4450 100644 --- a/kubernetes/client/models/v1_param_kind.py +++ b/kubernetes/client/models/v1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParamKind(BaseModel): diff --git a/kubernetes/client/models/v1_param_ref.py b/kubernetes/client/models/v1_param_ref.py index 17f0137158..96cd88dddd 100644 --- a/kubernetes/client/models/v1_param_ref.py +++ b/kubernetes/client/models/v1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParamRef(BaseModel): diff --git a/kubernetes/client/models/v1_parent_reference.py b/kubernetes/client/models/v1_parent_reference.py index f5bc03f8a3..23058f6e1c 100644 --- a/kubernetes/client/models/v1_parent_reference.py +++ b/kubernetes/client/models/v1_parent_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ParentReference(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume.py b/kubernetes/client/models/v1_persistent_volume.py index 6998742c3f..49d984c1b4 100644 --- a/kubernetes/client/models/v1_persistent_volume.py +++ b/kubernetes/client/models/v1_persistent_volume.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolume(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim.py b/kubernetes/client/models/v1_persistent_volume_claim.py index f1ec7112b9..409729d2fc 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim.py +++ b/kubernetes/client/models/v1_persistent_volume_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaim(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_condition.py b/kubernetes/client/models/v1_persistent_volume_claim_condition.py index ccf7f40688..caa13d5f40 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_condition.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimCondition(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_list.py b/kubernetes/client/models/v1_persistent_volume_claim_list.py index 032dddc47a..6748084683 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_list.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimList(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_spec.py b/kubernetes/client/models/v1_persistent_volume_claim_spec.py index 914b312970..3f1abbe44b 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_spec.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimSpec(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_status.py b/kubernetes/client/models/v1_persistent_volume_claim_status.py index 76b7f808d2..c87b21abbe 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_status.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_template.py b/kubernetes/client/models/v1_persistent_volume_claim_template.py index 23a000b03b..a1c8f873b8 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_template.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_template.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimTemplate(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_claim_volume_source.py b/kubernetes/client/models/v1_persistent_volume_claim_volume_source.py index ec31b38a19..4ccb152ab7 100644 --- a/kubernetes/client/models/v1_persistent_volume_claim_volume_source.py +++ b/kubernetes/client/models/v1_persistent_volume_claim_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeClaimVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_list.py b/kubernetes/client/models/v1_persistent_volume_list.py index 609dbb7279..cf635d7db7 100644 --- a/kubernetes/client/models/v1_persistent_volume_list.py +++ b/kubernetes/client/models/v1_persistent_volume_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeList(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_spec.py b/kubernetes/client/models/v1_persistent_volume_spec.py index 94ffc57496..fbb1ca36fb 100644 --- a/kubernetes/client/models/v1_persistent_volume_spec.py +++ b/kubernetes/client/models/v1_persistent_volume_spec.py @@ -49,72 +49,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeSpec(BaseModel): diff --git a/kubernetes/client/models/v1_persistent_volume_status.py b/kubernetes/client/models/v1_persistent_volume_status.py index f66360d971..a5c7957293 100644 --- a/kubernetes/client/models/v1_persistent_volume_status.py +++ b/kubernetes/client/models/v1_persistent_volume_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PersistentVolumeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_photon_persistent_disk_volume_source.py b/kubernetes/client/models/v1_photon_persistent_disk_volume_source.py index 311fe31e4c..ef77883daf 100644 --- a/kubernetes/client/models/v1_photon_persistent_disk_volume_source.py +++ b/kubernetes/client/models/v1_photon_persistent_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PhotonPersistentDiskVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_pod.py b/kubernetes/client/models/v1_pod.py index f7a8ec4d78..cf31322a7d 100644 --- a/kubernetes/client/models/v1_pod.py +++ b/kubernetes/client/models/v1_pod.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Pod(BaseModel): diff --git a/kubernetes/client/models/v1_pod_affinity.py b/kubernetes/client/models/v1_pod_affinity.py index 89ebb446e5..b1dbf6cc80 100644 --- a/kubernetes/client/models/v1_pod_affinity.py +++ b/kubernetes/client/models/v1_pod_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAffinity(BaseModel): diff --git a/kubernetes/client/models/v1_pod_affinity_term.py b/kubernetes/client/models/v1_pod_affinity_term.py index 99d41f882c..a77d9e1f2e 100644 --- a/kubernetes/client/models/v1_pod_affinity_term.py +++ b/kubernetes/client/models/v1_pod_affinity_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAffinityTerm(BaseModel): diff --git a/kubernetes/client/models/v1_pod_anti_affinity.py b/kubernetes/client/models/v1_pod_anti_affinity.py index b0b68441f7..2421119280 100644 --- a/kubernetes/client/models/v1_pod_anti_affinity.py +++ b/kubernetes/client/models/v1_pod_anti_affinity.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodAntiAffinity(BaseModel): diff --git a/kubernetes/client/models/v1_pod_certificate_projection.py b/kubernetes/client/models/v1_pod_certificate_projection.py index cef38ce24c..1a49b24c5c 100644 --- a/kubernetes/client/models/v1_pod_certificate_projection.py +++ b/kubernetes/client/models/v1_pod_certificate_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateProjection(BaseModel): diff --git a/kubernetes/client/models/v1_pod_certificate_request.py b/kubernetes/client/models/v1_pod_certificate_request.py index 085284430f..be5a199446 100644 --- a/kubernetes/client/models/v1_pod_certificate_request.py +++ b/kubernetes/client/models/v1_pod_certificate_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequest(BaseModel): diff --git a/kubernetes/client/models/v1_pod_certificate_request_list.py b/kubernetes/client/models/v1_pod_certificate_request_list.py index 61be5207ca..05593d087a 100644 --- a/kubernetes/client/models/v1_pod_certificate_request_list.py +++ b/kubernetes/client/models/v1_pod_certificate_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestList(BaseModel): diff --git a/kubernetes/client/models/v1_pod_certificate_request_spec.py b/kubernetes/client/models/v1_pod_certificate_request_spec.py index 281302e499..49db69cb0d 100644 --- a/kubernetes/client/models/v1_pod_certificate_request_spec.py +++ b/kubernetes/client/models/v1_pod_certificate_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1_pod_certificate_request_status.py b/kubernetes/client/models/v1_pod_certificate_request_status.py index e5893f8c32..90a489e44f 100644 --- a/kubernetes/client/models/v1_pod_certificate_request_status.py +++ b/kubernetes/client/models/v1_pod_certificate_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCertificateRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1_pod_condition.py b/kubernetes/client/models/v1_pod_condition.py index e583481c80..7de4551d9e 100644 --- a/kubernetes/client/models/v1_pod_condition.py +++ b/kubernetes/client/models/v1_pod_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodCondition(BaseModel): diff --git a/kubernetes/client/models/v1_pod_disruption_budget.py b/kubernetes/client/models/v1_pod_disruption_budget.py index 48ff936fe6..034b8d6853 100644 --- a/kubernetes/client/models/v1_pod_disruption_budget.py +++ b/kubernetes/client/models/v1_pod_disruption_budget.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudget(BaseModel): diff --git a/kubernetes/client/models/v1_pod_disruption_budget_list.py b/kubernetes/client/models/v1_pod_disruption_budget_list.py index bcf8873855..5574e984fb 100644 --- a/kubernetes/client/models/v1_pod_disruption_budget_list.py +++ b/kubernetes/client/models/v1_pod_disruption_budget_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetList(BaseModel): diff --git a/kubernetes/client/models/v1_pod_disruption_budget_spec.py b/kubernetes/client/models/v1_pod_disruption_budget_spec.py index 1770198ff0..9506ecaa7c 100644 --- a/kubernetes/client/models/v1_pod_disruption_budget_spec.py +++ b/kubernetes/client/models/v1_pod_disruption_budget_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetSpec(BaseModel): diff --git a/kubernetes/client/models/v1_pod_disruption_budget_status.py b/kubernetes/client/models/v1_pod_disruption_budget_status.py index 0c84e14c0c..f3d7dde638 100644 --- a/kubernetes/client/models/v1_pod_disruption_budget_status.py +++ b/kubernetes/client/models/v1_pod_disruption_budget_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDisruptionBudgetStatus(BaseModel): diff --git a/kubernetes/client/models/v1_pod_dns_config.py b/kubernetes/client/models/v1_pod_dns_config.py index 0294a043d9..b6e43f6025 100644 --- a/kubernetes/client/models/v1_pod_dns_config.py +++ b/kubernetes/client/models/v1_pod_dns_config.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDNSConfig(BaseModel): diff --git a/kubernetes/client/models/v1_pod_dns_config_option.py b/kubernetes/client/models/v1_pod_dns_config_option.py index 9423e570fa..2fde886aa0 100644 --- a/kubernetes/client/models/v1_pod_dns_config_option.py +++ b/kubernetes/client/models/v1_pod_dns_config_option.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodDNSConfigOption(BaseModel): diff --git a/kubernetes/client/models/v1_pod_extended_resource_claim_status.py b/kubernetes/client/models/v1_pod_extended_resource_claim_status.py index d289756e65..bd8ae4d42e 100644 --- a/kubernetes/client/models/v1_pod_extended_resource_claim_status.py +++ b/kubernetes/client/models/v1_pod_extended_resource_claim_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodExtendedResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1_pod_failure_policy.py b/kubernetes/client/models/v1_pod_failure_policy.py index 04487b8e41..e7c1c617dd 100644 --- a/kubernetes/client/models/v1_pod_failure_policy.py +++ b/kubernetes/client/models/v1_pod_failure_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicy(BaseModel): diff --git a/kubernetes/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py b/kubernetes/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py index 0210056405..0b3d0ffc18 100644 --- a/kubernetes/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py +++ b/kubernetes/client/models/v1_pod_failure_policy_on_exit_codes_requirement.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyOnExitCodesRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py b/kubernetes/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py index 459bcd9b5f..4f0dda4f55 100644 --- a/kubernetes/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py +++ b/kubernetes/client/models/v1_pod_failure_policy_on_pod_conditions_pattern.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyOnPodConditionsPattern(BaseModel): diff --git a/kubernetes/client/models/v1_pod_failure_policy_rule.py b/kubernetes/client/models/v1_pod_failure_policy_rule.py index f0557807bf..56f64545b5 100644 --- a/kubernetes/client/models/v1_pod_failure_policy_rule.py +++ b/kubernetes/client/models/v1_pod_failure_policy_rule.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodFailurePolicyRule(BaseModel): diff --git a/kubernetes/client/models/v1_pod_ip.py b/kubernetes/client/models/v1_pod_ip.py index 5b42a636ec..8a33030883 100644 --- a/kubernetes/client/models/v1_pod_ip.py +++ b/kubernetes/client/models/v1_pod_ip.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodIP(BaseModel): diff --git a/kubernetes/client/models/v1_pod_list.py b/kubernetes/client/models/v1_pod_list.py index 099d63b995..3a22910e7e 100644 --- a/kubernetes/client/models/v1_pod_list.py +++ b/kubernetes/client/models/v1_pod_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodList(BaseModel): diff --git a/kubernetes/client/models/v1_pod_os.py b/kubernetes/client/models/v1_pod_os.py index 61338f7806..e256aabd86 100644 --- a/kubernetes/client/models/v1_pod_os.py +++ b/kubernetes/client/models/v1_pod_os.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodOS(BaseModel): diff --git a/kubernetes/client/models/v1_pod_readiness_gate.py b/kubernetes/client/models/v1_pod_readiness_gate.py index f9e84a1dd6..59be7cbba7 100644 --- a/kubernetes/client/models/v1_pod_readiness_gate.py +++ b/kubernetes/client/models/v1_pod_readiness_gate.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodReadinessGate(BaseModel): diff --git a/kubernetes/client/models/v1_pod_resource_claim.py b/kubernetes/client/models/v1_pod_resource_claim.py index 26122ed300..c96f8fa7c3 100644 --- a/kubernetes/client/models/v1_pod_resource_claim.py +++ b/kubernetes/client/models/v1_pod_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1_pod_resource_claim_status.py b/kubernetes/client/models/v1_pod_resource_claim_status.py index abac45c06f..66d508ba55 100644 --- a/kubernetes/client/models/v1_pod_resource_claim_status.py +++ b/kubernetes/client/models/v1_pod_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1_pod_scheduling_gate.py b/kubernetes/client/models/v1_pod_scheduling_gate.py index f33128a719..ac9592c21b 100644 --- a/kubernetes/client/models/v1_pod_scheduling_gate.py +++ b/kubernetes/client/models/v1_pod_scheduling_gate.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSchedulingGate(BaseModel): diff --git a/kubernetes/client/models/v1_pod_scheduling_group.py b/kubernetes/client/models/v1_pod_scheduling_group.py index 651fe39523..80f9713c4f 100644 --- a/kubernetes/client/models/v1_pod_scheduling_group.py +++ b/kubernetes/client/models/v1_pod_scheduling_group.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSchedulingGroup(BaseModel): diff --git a/kubernetes/client/models/v1_pod_security_context.py b/kubernetes/client/models/v1_pod_security_context.py index 1ad3b28f55..d18b928402 100644 --- a/kubernetes/client/models/v1_pod_security_context.py +++ b/kubernetes/client/models/v1_pod_security_context.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSecurityContext(BaseModel): diff --git a/kubernetes/client/models/v1_pod_spec.py b/kubernetes/client/models/v1_pod_spec.py index 14dd90e6bf..cde5259789 100644 --- a/kubernetes/client/models/v1_pod_spec.py +++ b/kubernetes/client/models/v1_pod_spec.py @@ -42,72 +42,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodSpec(BaseModel): diff --git a/kubernetes/client/models/v1_pod_status.py b/kubernetes/client/models/v1_pod_status.py index f12f5cbbd8..13b05e6796 100644 --- a/kubernetes/client/models/v1_pod_status.py +++ b/kubernetes/client/models/v1_pod_status.py @@ -35,72 +35,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodStatus(BaseModel): diff --git a/kubernetes/client/models/v1_pod_template.py b/kubernetes/client/models/v1_pod_template.py index 489af7c91b..d2e5103821 100644 --- a/kubernetes/client/models/v1_pod_template.py +++ b/kubernetes/client/models/v1_pod_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplate(BaseModel): diff --git a/kubernetes/client/models/v1_pod_template_list.py b/kubernetes/client/models/v1_pod_template_list.py index 6c42e167b3..d68f60512b 100644 --- a/kubernetes/client/models/v1_pod_template_list.py +++ b/kubernetes/client/models/v1_pod_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplateList(BaseModel): diff --git a/kubernetes/client/models/v1_pod_template_spec.py b/kubernetes/client/models/v1_pod_template_spec.py index 54a7d48119..fdcf6e76f8 100644 --- a/kubernetes/client/models/v1_pod_template_spec.py +++ b/kubernetes/client/models/v1_pod_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodTemplateSpec(BaseModel): diff --git a/kubernetes/client/models/v1_pod_volume_health.py b/kubernetes/client/models/v1_pod_volume_health.py index 3f5c8c58f6..d80936d790 100644 --- a/kubernetes/client/models/v1_pod_volume_health.py +++ b/kubernetes/client/models/v1_pod_volume_health.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PodVolumeHealth(BaseModel): diff --git a/kubernetes/client/models/v1_policy_rule.py b/kubernetes/client/models/v1_policy_rule.py index f56df5a070..1221eb0aea 100644 --- a/kubernetes/client/models/v1_policy_rule.py +++ b/kubernetes/client/models/v1_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PolicyRule(BaseModel): diff --git a/kubernetes/client/models/v1_policy_rules_with_subjects.py b/kubernetes/client/models/v1_policy_rules_with_subjects.py index 6862b3d679..c1368dd454 100644 --- a/kubernetes/client/models/v1_policy_rules_with_subjects.py +++ b/kubernetes/client/models/v1_policy_rules_with_subjects.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PolicyRulesWithSubjects(BaseModel): diff --git a/kubernetes/client/models/v1_port_status.py b/kubernetes/client/models/v1_port_status.py index ef18c7f023..17b6ede184 100644 --- a/kubernetes/client/models/v1_port_status.py +++ b/kubernetes/client/models/v1_port_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PortStatus(BaseModel): diff --git a/kubernetes/client/models/v1_portworx_volume_source.py b/kubernetes/client/models/v1_portworx_volume_source.py index df1e32333c..a4a2cc53a1 100644 --- a/kubernetes/client/models/v1_portworx_volume_source.py +++ b/kubernetes/client/models/v1_portworx_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PortworxVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_preconditions.py b/kubernetes/client/models/v1_preconditions.py index 464be0f68b..cc5835f10e 100644 --- a/kubernetes/client/models/v1_preconditions.py +++ b/kubernetes/client/models/v1_preconditions.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Preconditions(BaseModel): diff --git a/kubernetes/client/models/v1_preferred_scheduling_term.py b/kubernetes/client/models/v1_preferred_scheduling_term.py index b1851b63ff..2bee8f0041 100644 --- a/kubernetes/client/models/v1_preferred_scheduling_term.py +++ b/kubernetes/client/models/v1_preferred_scheduling_term.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PreferredSchedulingTerm(BaseModel): diff --git a/kubernetes/client/models/v1_priority_class.py b/kubernetes/client/models/v1_priority_class.py index 3c0fb73c79..7ece139b71 100644 --- a/kubernetes/client/models/v1_priority_class.py +++ b/kubernetes/client/models/v1_priority_class.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityClass(BaseModel): diff --git a/kubernetes/client/models/v1_priority_class_list.py b/kubernetes/client/models/v1_priority_class_list.py index 26eb4df927..66476ce9bc 100644 --- a/kubernetes/client/models/v1_priority_class_list.py +++ b/kubernetes/client/models/v1_priority_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityClassList(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration.py b/kubernetes/client/models/v1_priority_level_configuration.py index 439b9fb0b0..5bff363fcd 100644 --- a/kubernetes/client/models/v1_priority_level_configuration.py +++ b/kubernetes/client/models/v1_priority_level_configuration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration_condition.py b/kubernetes/client/models/v1_priority_level_configuration_condition.py index c99da95a13..a58e36ce14 100644 --- a/kubernetes/client/models/v1_priority_level_configuration_condition.py +++ b/kubernetes/client/models/v1_priority_level_configuration_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationCondition(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration_list.py b/kubernetes/client/models/v1_priority_level_configuration_list.py index b67f99a9dc..b0e2792b6e 100644 --- a/kubernetes/client/models/v1_priority_level_configuration_list.py +++ b/kubernetes/client/models/v1_priority_level_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationList(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration_reference.py b/kubernetes/client/models/v1_priority_level_configuration_reference.py index 22e52bf36a..459ee0766c 100644 --- a/kubernetes/client/models/v1_priority_level_configuration_reference.py +++ b/kubernetes/client/models/v1_priority_level_configuration_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationReference(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration_spec.py b/kubernetes/client/models/v1_priority_level_configuration_spec.py index 8ea2c97fb1..a8e08b2b9b 100644 --- a/kubernetes/client/models/v1_priority_level_configuration_spec.py +++ b/kubernetes/client/models/v1_priority_level_configuration_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationSpec(BaseModel): diff --git a/kubernetes/client/models/v1_priority_level_configuration_status.py b/kubernetes/client/models/v1_priority_level_configuration_status.py index 1d3ba1faf9..1f893c0bb7 100644 --- a/kubernetes/client/models/v1_priority_level_configuration_status.py +++ b/kubernetes/client/models/v1_priority_level_configuration_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1PriorityLevelConfigurationStatus(BaseModel): diff --git a/kubernetes/client/models/v1_probe.py b/kubernetes/client/models/v1_probe.py index 8f9f32fbb7..482efc66e8 100644 --- a/kubernetes/client/models/v1_probe.py +++ b/kubernetes/client/models/v1_probe.py @@ -30,72 +30,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Probe(BaseModel): diff --git a/kubernetes/client/models/v1_projected_volume_source.py b/kubernetes/client/models/v1_projected_volume_source.py index 59fce9d89f..3529c36337 100644 --- a/kubernetes/client/models/v1_projected_volume_source.py +++ b/kubernetes/client/models/v1_projected_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ProjectedVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_queuing_configuration.py b/kubernetes/client/models/v1_queuing_configuration.py index 3bf8ee6e2b..d3d5d58b88 100644 --- a/kubernetes/client/models/v1_queuing_configuration.py +++ b/kubernetes/client/models/v1_queuing_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1QueuingConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_quobyte_volume_source.py b/kubernetes/client/models/v1_quobyte_volume_source.py index 1631e7452b..ddcf8d8d9c 100644 --- a/kubernetes/client/models/v1_quobyte_volume_source.py +++ b/kubernetes/client/models/v1_quobyte_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1QuobyteVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_rbd_persistent_volume_source.py b/kubernetes/client/models/v1_rbd_persistent_volume_source.py index c347a52183..883aee6746 100644 --- a/kubernetes/client/models/v1_rbd_persistent_volume_source.py +++ b/kubernetes/client/models/v1_rbd_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RBDPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_rbd_volume_source.py b/kubernetes/client/models/v1_rbd_volume_source.py index 57a14a7359..ca55d82986 100644 --- a/kubernetes/client/models/v1_rbd_volume_source.py +++ b/kubernetes/client/models/v1_rbd_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RBDVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_replica_set.py b/kubernetes/client/models/v1_replica_set.py index 96630cb945..ab79d27a1f 100644 --- a/kubernetes/client/models/v1_replica_set.py +++ b/kubernetes/client/models/v1_replica_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSet(BaseModel): diff --git a/kubernetes/client/models/v1_replica_set_condition.py b/kubernetes/client/models/v1_replica_set_condition.py index a64a0300a7..34b8b6214e 100644 --- a/kubernetes/client/models/v1_replica_set_condition.py +++ b/kubernetes/client/models/v1_replica_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetCondition(BaseModel): diff --git a/kubernetes/client/models/v1_replica_set_list.py b/kubernetes/client/models/v1_replica_set_list.py index eb61a091f1..63ff24b1d5 100644 --- a/kubernetes/client/models/v1_replica_set_list.py +++ b/kubernetes/client/models/v1_replica_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetList(BaseModel): diff --git a/kubernetes/client/models/v1_replica_set_spec.py b/kubernetes/client/models/v1_replica_set_spec.py index 99d817c061..6de3d4bca6 100644 --- a/kubernetes/client/models/v1_replica_set_spec.py +++ b/kubernetes/client/models/v1_replica_set_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetSpec(BaseModel): diff --git a/kubernetes/client/models/v1_replica_set_status.py b/kubernetes/client/models/v1_replica_set_status.py index 7d3f2503e3..3e1bd98a73 100644 --- a/kubernetes/client/models/v1_replica_set_status.py +++ b/kubernetes/client/models/v1_replica_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicaSetStatus(BaseModel): diff --git a/kubernetes/client/models/v1_replication_controller.py b/kubernetes/client/models/v1_replication_controller.py index 5e29db7cc4..d225e4fc12 100644 --- a/kubernetes/client/models/v1_replication_controller.py +++ b/kubernetes/client/models/v1_replication_controller.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationController(BaseModel): diff --git a/kubernetes/client/models/v1_replication_controller_condition.py b/kubernetes/client/models/v1_replication_controller_condition.py index 640c824fa5..90e99af84a 100644 --- a/kubernetes/client/models/v1_replication_controller_condition.py +++ b/kubernetes/client/models/v1_replication_controller_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerCondition(BaseModel): diff --git a/kubernetes/client/models/v1_replication_controller_list.py b/kubernetes/client/models/v1_replication_controller_list.py index 3a2001fba8..84f335b98f 100644 --- a/kubernetes/client/models/v1_replication_controller_list.py +++ b/kubernetes/client/models/v1_replication_controller_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerList(BaseModel): diff --git a/kubernetes/client/models/v1_replication_controller_spec.py b/kubernetes/client/models/v1_replication_controller_spec.py index 03110c3d84..89e6add91b 100644 --- a/kubernetes/client/models/v1_replication_controller_spec.py +++ b/kubernetes/client/models/v1_replication_controller_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerSpec(BaseModel): diff --git a/kubernetes/client/models/v1_replication_controller_status.py b/kubernetes/client/models/v1_replication_controller_status.py index 7a00781b63..0bc5a4f686 100644 --- a/kubernetes/client/models/v1_replication_controller_status.py +++ b/kubernetes/client/models/v1_replication_controller_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ReplicationControllerStatus(BaseModel): diff --git a/kubernetes/client/models/v1_resource_attributes.py b/kubernetes/client/models/v1_resource_attributes.py index bb480d6257..4707652cbe 100644 --- a/kubernetes/client/models/v1_resource_attributes.py +++ b/kubernetes/client/models/v1_resource_attributes.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceAttributes(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_consumer_reference.py b/kubernetes/client/models/v1_resource_claim_consumer_reference.py index 8909a0a879..54ef5e25a2 100644 --- a/kubernetes/client/models/v1_resource_claim_consumer_reference.py +++ b/kubernetes/client/models/v1_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_list.py b/kubernetes/client/models/v1_resource_claim_list.py index 898142976e..d3f837c200 100644 --- a/kubernetes/client/models/v1_resource_claim_list.py +++ b/kubernetes/client/models/v1_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimList(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_spec.py b/kubernetes/client/models/v1_resource_claim_spec.py index b7fa44b8a3..8ef8ffe9b9 100644 --- a/kubernetes/client/models/v1_resource_claim_spec.py +++ b/kubernetes/client/models/v1_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimSpec(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_status.py b/kubernetes/client/models/v1_resource_claim_status.py index d219bc6cd1..dec5f443c4 100644 --- a/kubernetes/client/models/v1_resource_claim_status.py +++ b/kubernetes/client/models/v1_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_template.py b/kubernetes/client/models/v1_resource_claim_template.py index 82c13a802e..6ec99a76b5 100644 --- a/kubernetes/client/models/v1_resource_claim_template.py +++ b/kubernetes/client/models/v1_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_template_list.py b/kubernetes/client/models/v1_resource_claim_template_list.py index b39dda655a..5d032d8580 100644 --- a/kubernetes/client/models/v1_resource_claim_template_list.py +++ b/kubernetes/client/models/v1_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/client/models/v1_resource_claim_template_spec.py b/kubernetes/client/models/v1_resource_claim_template_spec.py index 1f77d73e7a..2236878f13 100644 --- a/kubernetes/client/models/v1_resource_claim_template_spec.py +++ b/kubernetes/client/models/v1_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/client/models/v1_resource_field_selector.py b/kubernetes/client/models/v1_resource_field_selector.py index 4c8ff82c36..67fba96329 100644 --- a/kubernetes/client/models/v1_resource_field_selector.py +++ b/kubernetes/client/models/v1_resource_field_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceFieldSelector(BaseModel): diff --git a/kubernetes/client/models/v1_resource_health.py b/kubernetes/client/models/v1_resource_health.py index 1f5c3ecf0e..0d22180a86 100644 --- a/kubernetes/client/models/v1_resource_health.py +++ b/kubernetes/client/models/v1_resource_health.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceHealth(BaseModel): diff --git a/kubernetes/client/models/v1_resource_policy_rule.py b/kubernetes/client/models/v1_resource_policy_rule.py index a2075c8d8a..03bda7582b 100644 --- a/kubernetes/client/models/v1_resource_policy_rule.py +++ b/kubernetes/client/models/v1_resource_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourcePolicyRule(BaseModel): diff --git a/kubernetes/client/models/v1_resource_pool.py b/kubernetes/client/models/v1_resource_pool.py index 4f7a43c136..2ec2cef89c 100644 --- a/kubernetes/client/models/v1_resource_pool.py +++ b/kubernetes/client/models/v1_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourcePool(BaseModel): diff --git a/kubernetes/client/models/v1_resource_quota.py b/kubernetes/client/models/v1_resource_quota.py index 176e67b544..d0b0223ebf 100644 --- a/kubernetes/client/models/v1_resource_quota.py +++ b/kubernetes/client/models/v1_resource_quota.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuota(BaseModel): diff --git a/kubernetes/client/models/v1_resource_quota_list.py b/kubernetes/client/models/v1_resource_quota_list.py index bed2f3c192..e88260483a 100644 --- a/kubernetes/client/models/v1_resource_quota_list.py +++ b/kubernetes/client/models/v1_resource_quota_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaList(BaseModel): diff --git a/kubernetes/client/models/v1_resource_quota_spec.py b/kubernetes/client/models/v1_resource_quota_spec.py index 1aeb829989..798f316750 100644 --- a/kubernetes/client/models/v1_resource_quota_spec.py +++ b/kubernetes/client/models/v1_resource_quota_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaSpec(BaseModel): diff --git a/kubernetes/client/models/v1_resource_quota_status.py b/kubernetes/client/models/v1_resource_quota_status.py index a170899577..3720194f24 100644 --- a/kubernetes/client/models/v1_resource_quota_status.py +++ b/kubernetes/client/models/v1_resource_quota_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceQuotaStatus(BaseModel): diff --git a/kubernetes/client/models/v1_resource_requirements.py b/kubernetes/client/models/v1_resource_requirements.py index 486990228b..d88de41958 100644 --- a/kubernetes/client/models/v1_resource_requirements.py +++ b/kubernetes/client/models/v1_resource_requirements.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceRequirements(BaseModel): diff --git a/kubernetes/client/models/v1_resource_rule.py b/kubernetes/client/models/v1_resource_rule.py index c18e371291..1863ae1329 100644 --- a/kubernetes/client/models/v1_resource_rule.py +++ b/kubernetes/client/models/v1_resource_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceRule(BaseModel): diff --git a/kubernetes/client/models/v1_resource_slice.py b/kubernetes/client/models/v1_resource_slice.py index 8e752e3cdf..08a665d36c 100644 --- a/kubernetes/client/models/v1_resource_slice.py +++ b/kubernetes/client/models/v1_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSlice(BaseModel): diff --git a/kubernetes/client/models/v1_resource_slice_list.py b/kubernetes/client/models/v1_resource_slice_list.py index c115176874..913da33f39 100644 --- a/kubernetes/client/models/v1_resource_slice_list.py +++ b/kubernetes/client/models/v1_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSliceList(BaseModel): diff --git a/kubernetes/client/models/v1_resource_slice_spec.py b/kubernetes/client/models/v1_resource_slice_spec.py index efec5a17af..f1cf7ececa 100644 --- a/kubernetes/client/models/v1_resource_slice_spec.py +++ b/kubernetes/client/models/v1_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceSliceSpec(BaseModel): diff --git a/kubernetes/client/models/v1_resource_status.py b/kubernetes/client/models/v1_resource_status.py index 3d0b49cb92..543c16aa57 100644 --- a/kubernetes/client/models/v1_resource_status.py +++ b/kubernetes/client/models/v1_resource_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ResourceStatus(BaseModel): diff --git a/kubernetes/client/models/v1_role.py b/kubernetes/client/models/v1_role.py index 5947917a67..eca08dc9b7 100644 --- a/kubernetes/client/models/v1_role.py +++ b/kubernetes/client/models/v1_role.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Role(BaseModel): diff --git a/kubernetes/client/models/v1_role_binding.py b/kubernetes/client/models/v1_role_binding.py index b4eda1c961..4bed76ae4c 100644 --- a/kubernetes/client/models/v1_role_binding.py +++ b/kubernetes/client/models/v1_role_binding.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleBinding(BaseModel): diff --git a/kubernetes/client/models/v1_role_binding_list.py b/kubernetes/client/models/v1_role_binding_list.py index 18916c5a6b..3ff8ad5945 100644 --- a/kubernetes/client/models/v1_role_binding_list.py +++ b/kubernetes/client/models/v1_role_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleBindingList(BaseModel): diff --git a/kubernetes/client/models/v1_role_list.py b/kubernetes/client/models/v1_role_list.py index 7acf3d0cfa..5fd4173b65 100644 --- a/kubernetes/client/models/v1_role_list.py +++ b/kubernetes/client/models/v1_role_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleList(BaseModel): diff --git a/kubernetes/client/models/v1_role_ref.py b/kubernetes/client/models/v1_role_ref.py index f795fe539d..6451d19d6b 100644 --- a/kubernetes/client/models/v1_role_ref.py +++ b/kubernetes/client/models/v1_role_ref.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RoleRef(BaseModel): diff --git a/kubernetes/client/models/v1_rolling_update_daemon_set.py b/kubernetes/client/models/v1_rolling_update_daemon_set.py index b5c84a2cc4..ff1ed75ac6 100644 --- a/kubernetes/client/models/v1_rolling_update_daemon_set.py +++ b/kubernetes/client/models/v1_rolling_update_daemon_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateDaemonSet(BaseModel): diff --git a/kubernetes/client/models/v1_rolling_update_deployment.py b/kubernetes/client/models/v1_rolling_update_deployment.py index 706e494e2b..138c361e6e 100644 --- a/kubernetes/client/models/v1_rolling_update_deployment.py +++ b/kubernetes/client/models/v1_rolling_update_deployment.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateDeployment(BaseModel): diff --git a/kubernetes/client/models/v1_rolling_update_stateful_set_strategy.py b/kubernetes/client/models/v1_rolling_update_stateful_set_strategy.py index ab2c7ce46f..6d3675e1b9 100644 --- a/kubernetes/client/models/v1_rolling_update_stateful_set_strategy.py +++ b/kubernetes/client/models/v1_rolling_update_stateful_set_strategy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RollingUpdateStatefulSetStrategy(BaseModel): diff --git a/kubernetes/client/models/v1_rule_with_operations.py b/kubernetes/client/models/v1_rule_with_operations.py index a8919e828a..c0e78e538c 100644 --- a/kubernetes/client/models/v1_rule_with_operations.py +++ b/kubernetes/client/models/v1_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuleWithOperations(BaseModel): diff --git a/kubernetes/client/models/v1_runtime_class.py b/kubernetes/client/models/v1_runtime_class.py index 3b2dd78df9..0d4f67112a 100644 --- a/kubernetes/client/models/v1_runtime_class.py +++ b/kubernetes/client/models/v1_runtime_class.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuntimeClass(BaseModel): diff --git a/kubernetes/client/models/v1_runtime_class_list.py b/kubernetes/client/models/v1_runtime_class_list.py index 4215c0afa6..63bfd739c2 100644 --- a/kubernetes/client/models/v1_runtime_class_list.py +++ b/kubernetes/client/models/v1_runtime_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1RuntimeClassList(BaseModel): diff --git a/kubernetes/client/models/v1_scale.py b/kubernetes/client/models/v1_scale.py index 34c5e5f92d..0f1e57fffa 100644 --- a/kubernetes/client/models/v1_scale.py +++ b/kubernetes/client/models/v1_scale.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Scale(BaseModel): diff --git a/kubernetes/client/models/v1_scale_io_persistent_volume_source.py b/kubernetes/client/models/v1_scale_io_persistent_volume_source.py index 15948748d8..a71fb00b72 100644 --- a/kubernetes/client/models/v1_scale_io_persistent_volume_source.py +++ b/kubernetes/client/models/v1_scale_io_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleIOPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_scale_io_volume_source.py b/kubernetes/client/models/v1_scale_io_volume_source.py index fc33398709..6331c1126f 100644 --- a/kubernetes/client/models/v1_scale_io_volume_source.py +++ b/kubernetes/client/models/v1_scale_io_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleIOVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_scale_spec.py b/kubernetes/client/models/v1_scale_spec.py index 6908e005b3..19f7f7b042 100644 --- a/kubernetes/client/models/v1_scale_spec.py +++ b/kubernetes/client/models/v1_scale_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleSpec(BaseModel): diff --git a/kubernetes/client/models/v1_scale_status.py b/kubernetes/client/models/v1_scale_status.py index 043ee818dd..a0431865f6 100644 --- a/kubernetes/client/models/v1_scale_status.py +++ b/kubernetes/client/models/v1_scale_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScaleStatus(BaseModel): diff --git a/kubernetes/client/models/v1_scheduling.py b/kubernetes/client/models/v1_scheduling.py index ef292fd0a7..695efa8190 100644 --- a/kubernetes/client/models/v1_scheduling.py +++ b/kubernetes/client/models/v1_scheduling.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Scheduling(BaseModel): diff --git a/kubernetes/client/models/v1_scope_selector.py b/kubernetes/client/models/v1_scope_selector.py index b7f7149042..c5d5e97ada 100644 --- a/kubernetes/client/models/v1_scope_selector.py +++ b/kubernetes/client/models/v1_scope_selector.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScopeSelector(BaseModel): diff --git a/kubernetes/client/models/v1_scoped_resource_selector_requirement.py b/kubernetes/client/models/v1_scoped_resource_selector_requirement.py index e7a67ac25c..d30c8289f3 100644 --- a/kubernetes/client/models/v1_scoped_resource_selector_requirement.py +++ b/kubernetes/client/models/v1_scoped_resource_selector_requirement.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ScopedResourceSelectorRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_se_linux_options.py b/kubernetes/client/models/v1_se_linux_options.py index 3a76a3ec8d..0952bc064b 100644 --- a/kubernetes/client/models/v1_se_linux_options.py +++ b/kubernetes/client/models/v1_se_linux_options.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SELinuxOptions(BaseModel): diff --git a/kubernetes/client/models/v1_seccomp_profile.py b/kubernetes/client/models/v1_seccomp_profile.py index b531095416..994b3382b3 100644 --- a/kubernetes/client/models/v1_seccomp_profile.py +++ b/kubernetes/client/models/v1_seccomp_profile.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SeccompProfile(BaseModel): diff --git a/kubernetes/client/models/v1_secret.py b/kubernetes/client/models/v1_secret.py index 3a68f845c9..91cdefb9ff 100644 --- a/kubernetes/client/models/v1_secret.py +++ b/kubernetes/client/models/v1_secret.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Secret(BaseModel): diff --git a/kubernetes/client/models/v1_secret_env_source.py b/kubernetes/client/models/v1_secret_env_source.py index 7cff1f38b2..9fc32fa1f0 100644 --- a/kubernetes/client/models/v1_secret_env_source.py +++ b/kubernetes/client/models/v1_secret_env_source.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretEnvSource(BaseModel): diff --git a/kubernetes/client/models/v1_secret_key_selector.py b/kubernetes/client/models/v1_secret_key_selector.py index 2c3a8e6c1e..3c410d5c7c 100644 --- a/kubernetes/client/models/v1_secret_key_selector.py +++ b/kubernetes/client/models/v1_secret_key_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretKeySelector(BaseModel): diff --git a/kubernetes/client/models/v1_secret_list.py b/kubernetes/client/models/v1_secret_list.py index ce16fb027d..a6ddfe48d5 100644 --- a/kubernetes/client/models/v1_secret_list.py +++ b/kubernetes/client/models/v1_secret_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretList(BaseModel): diff --git a/kubernetes/client/models/v1_secret_projection.py b/kubernetes/client/models/v1_secret_projection.py index dc786a1267..8e9514caf0 100644 --- a/kubernetes/client/models/v1_secret_projection.py +++ b/kubernetes/client/models/v1_secret_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretProjection(BaseModel): diff --git a/kubernetes/client/models/v1_secret_reference.py b/kubernetes/client/models/v1_secret_reference.py index e67fc9ec1c..f58d84b618 100644 --- a/kubernetes/client/models/v1_secret_reference.py +++ b/kubernetes/client/models/v1_secret_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretReference(BaseModel): diff --git a/kubernetes/client/models/v1_secret_volume_source.py b/kubernetes/client/models/v1_secret_volume_source.py index f6d20412a5..8a977eeabd 100644 --- a/kubernetes/client/models/v1_secret_volume_source.py +++ b/kubernetes/client/models/v1_secret_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecretVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_security_context.py b/kubernetes/client/models/v1_security_context.py index ef5ea50c33..5f962682a1 100644 --- a/kubernetes/client/models/v1_security_context.py +++ b/kubernetes/client/models/v1_security_context.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SecurityContext(BaseModel): diff --git a/kubernetes/client/models/v1_selectable_field.py b/kubernetes/client/models/v1_selectable_field.py index c764f79825..79c820f893 100644 --- a/kubernetes/client/models/v1_selectable_field.py +++ b/kubernetes/client/models/v1_selectable_field.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelectableField(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_access_review.py b/kubernetes/client/models/v1_self_subject_access_review.py index 1e2110f489..155efcc710 100644 --- a/kubernetes/client/models/v1_self_subject_access_review.py +++ b/kubernetes/client/models/v1_self_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectAccessReview(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_access_review_spec.py b/kubernetes/client/models/v1_self_subject_access_review_spec.py index 0c7c3512ac..1520365fc1 100644 --- a/kubernetes/client/models/v1_self_subject_access_review_spec.py +++ b/kubernetes/client/models/v1_self_subject_access_review_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectAccessReviewSpec(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_review.py b/kubernetes/client/models/v1_self_subject_review.py index de3725afdf..b035a0132b 100644 --- a/kubernetes/client/models/v1_self_subject_review.py +++ b/kubernetes/client/models/v1_self_subject_review.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectReview(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_review_status.py b/kubernetes/client/models/v1_self_subject_review_status.py index 5dc14950d9..457606e8b7 100644 --- a/kubernetes/client/models/v1_self_subject_review_status.py +++ b/kubernetes/client/models/v1_self_subject_review_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectReviewStatus(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_rules_review.py b/kubernetes/client/models/v1_self_subject_rules_review.py index 1a9d065e3c..4008efad96 100644 --- a/kubernetes/client/models/v1_self_subject_rules_review.py +++ b/kubernetes/client/models/v1_self_subject_rules_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectRulesReview(BaseModel): diff --git a/kubernetes/client/models/v1_self_subject_rules_review_spec.py b/kubernetes/client/models/v1_self_subject_rules_review_spec.py index eaa8a036b7..c4dda9d176 100644 --- a/kubernetes/client/models/v1_self_subject_rules_review_spec.py +++ b/kubernetes/client/models/v1_self_subject_rules_review_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SelfSubjectRulesReviewSpec(BaseModel): diff --git a/kubernetes/client/models/v1_server_address_by_client_cidr.py b/kubernetes/client/models/v1_server_address_by_client_cidr.py index e556be1eda..2f4b8abb7c 100644 --- a/kubernetes/client/models/v1_server_address_by_client_cidr.py +++ b/kubernetes/client/models/v1_server_address_by_client_cidr.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServerAddressByClientCIDR(BaseModel): diff --git a/kubernetes/client/models/v1_service.py b/kubernetes/client/models/v1_service.py index 2f2026d78b..35327fbcde 100644 --- a/kubernetes/client/models/v1_service.py +++ b/kubernetes/client/models/v1_service.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Service(BaseModel): diff --git a/kubernetes/client/models/v1_service_account.py b/kubernetes/client/models/v1_service_account.py index 2832dc9917..6aa24ac2ee 100644 --- a/kubernetes/client/models/v1_service_account.py +++ b/kubernetes/client/models/v1_service_account.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccount(BaseModel): diff --git a/kubernetes/client/models/v1_service_account_list.py b/kubernetes/client/models/v1_service_account_list.py index 77444a8c2a..b4c44dbda8 100644 --- a/kubernetes/client/models/v1_service_account_list.py +++ b/kubernetes/client/models/v1_service_account_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountList(BaseModel): diff --git a/kubernetes/client/models/v1_service_account_subject.py b/kubernetes/client/models/v1_service_account_subject.py index 4c2364d615..54c483950e 100644 --- a/kubernetes/client/models/v1_service_account_subject.py +++ b/kubernetes/client/models/v1_service_account_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountSubject(BaseModel): diff --git a/kubernetes/client/models/v1_service_account_token_projection.py b/kubernetes/client/models/v1_service_account_token_projection.py index ca757d2b21..54caf1f3a3 100644 --- a/kubernetes/client/models/v1_service_account_token_projection.py +++ b/kubernetes/client/models/v1_service_account_token_projection.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceAccountTokenProjection(BaseModel): diff --git a/kubernetes/client/models/v1_service_backend_port.py b/kubernetes/client/models/v1_service_backend_port.py index 3777a294bb..6e2a67a90e 100644 --- a/kubernetes/client/models/v1_service_backend_port.py +++ b/kubernetes/client/models/v1_service_backend_port.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceBackendPort(BaseModel): diff --git a/kubernetes/client/models/v1_service_cidr.py b/kubernetes/client/models/v1_service_cidr.py index d31f9c7d53..061ad0c9d0 100644 --- a/kubernetes/client/models/v1_service_cidr.py +++ b/kubernetes/client/models/v1_service_cidr.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDR(BaseModel): diff --git a/kubernetes/client/models/v1_service_cidr_list.py b/kubernetes/client/models/v1_service_cidr_list.py index 3b8efea5e5..720865c16c 100644 --- a/kubernetes/client/models/v1_service_cidr_list.py +++ b/kubernetes/client/models/v1_service_cidr_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRList(BaseModel): diff --git a/kubernetes/client/models/v1_service_cidr_spec.py b/kubernetes/client/models/v1_service_cidr_spec.py index 9ae607d7d5..1b720209f0 100644 --- a/kubernetes/client/models/v1_service_cidr_spec.py +++ b/kubernetes/client/models/v1_service_cidr_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRSpec(BaseModel): diff --git a/kubernetes/client/models/v1_service_cidr_status.py b/kubernetes/client/models/v1_service_cidr_status.py index d749783a1b..7070cfe651 100644 --- a/kubernetes/client/models/v1_service_cidr_status.py +++ b/kubernetes/client/models/v1_service_cidr_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceCIDRStatus(BaseModel): diff --git a/kubernetes/client/models/v1_service_list.py b/kubernetes/client/models/v1_service_list.py index 149f2ec8a5..c3f86bca22 100644 --- a/kubernetes/client/models/v1_service_list.py +++ b/kubernetes/client/models/v1_service_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceList(BaseModel): diff --git a/kubernetes/client/models/v1_service_port.py b/kubernetes/client/models/v1_service_port.py index ba5625f214..0014774485 100644 --- a/kubernetes/client/models/v1_service_port.py +++ b/kubernetes/client/models/v1_service_port.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServicePort(BaseModel): diff --git a/kubernetes/client/models/v1_service_spec.py b/kubernetes/client/models/v1_service_spec.py index 34458363be..27b1d583cd 100644 --- a/kubernetes/client/models/v1_service_spec.py +++ b/kubernetes/client/models/v1_service_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceSpec(BaseModel): diff --git a/kubernetes/client/models/v1_service_status.py b/kubernetes/client/models/v1_service_status.py index 7360dba0f3..91d5468105 100644 --- a/kubernetes/client/models/v1_service_status.py +++ b/kubernetes/client/models/v1_service_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ServiceStatus(BaseModel): diff --git a/kubernetes/client/models/v1_session_affinity_config.py b/kubernetes/client/models/v1_session_affinity_config.py index 1ab3e069b1..9e4c2d601c 100644 --- a/kubernetes/client/models/v1_session_affinity_config.py +++ b/kubernetes/client/models/v1_session_affinity_config.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SessionAffinityConfig(BaseModel): diff --git a/kubernetes/client/models/v1_shard_info.py b/kubernetes/client/models/v1_shard_info.py index c8e9d75e9f..ee1c60b690 100644 --- a/kubernetes/client/models/v1_shard_info.py +++ b/kubernetes/client/models/v1_shard_info.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ShardInfo(BaseModel): diff --git a/kubernetes/client/models/v1_sleep_action.py b/kubernetes/client/models/v1_sleep_action.py index df6733738e..fecd1ea836 100644 --- a/kubernetes/client/models/v1_sleep_action.py +++ b/kubernetes/client/models/v1_sleep_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SleepAction(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set.py b/kubernetes/client/models/v1_stateful_set.py index 74e65a1dea..ebdddc5769 100644 --- a/kubernetes/client/models/v1_stateful_set.py +++ b/kubernetes/client/models/v1_stateful_set.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSet(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_condition.py b/kubernetes/client/models/v1_stateful_set_condition.py index a223e6d709..6afe4049aa 100644 --- a/kubernetes/client/models/v1_stateful_set_condition.py +++ b/kubernetes/client/models/v1_stateful_set_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetCondition(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_list.py b/kubernetes/client/models/v1_stateful_set_list.py index 0b76a360f7..34ac5dfcd6 100644 --- a/kubernetes/client/models/v1_stateful_set_list.py +++ b/kubernetes/client/models/v1_stateful_set_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetList(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_ordinals.py b/kubernetes/client/models/v1_stateful_set_ordinals.py index 115fdd2332..6f5fd21b72 100644 --- a/kubernetes/client/models/v1_stateful_set_ordinals.py +++ b/kubernetes/client/models/v1_stateful_set_ordinals.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetOrdinals(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py b/kubernetes/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py index e0de442c50..b3f85f0973 100644 --- a/kubernetes/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py +++ b/kubernetes/client/models/v1_stateful_set_persistent_volume_claim_retention_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetPersistentVolumeClaimRetentionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_spec.py b/kubernetes/client/models/v1_stateful_set_spec.py index db1fe4a8f4..ae2b2be5b0 100644 --- a/kubernetes/client/models/v1_stateful_set_spec.py +++ b/kubernetes/client/models/v1_stateful_set_spec.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetSpec(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_status.py b/kubernetes/client/models/v1_stateful_set_status.py index fe7eb8428f..1d383167ad 100644 --- a/kubernetes/client/models/v1_stateful_set_status.py +++ b/kubernetes/client/models/v1_stateful_set_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetStatus(BaseModel): diff --git a/kubernetes/client/models/v1_stateful_set_update_strategy.py b/kubernetes/client/models/v1_stateful_set_update_strategy.py index 53c7c54f08..3879ce9c7e 100644 --- a/kubernetes/client/models/v1_stateful_set_update_strategy.py +++ b/kubernetes/client/models/v1_stateful_set_update_strategy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatefulSetUpdateStrategy(BaseModel): diff --git a/kubernetes/client/models/v1_status.py b/kubernetes/client/models/v1_status.py index cba64275b4..7f24e2720d 100644 --- a/kubernetes/client/models/v1_status.py +++ b/kubernetes/client/models/v1_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Status(BaseModel): diff --git a/kubernetes/client/models/v1_status_cause.py b/kubernetes/client/models/v1_status_cause.py index b72089803a..9cdea406d1 100644 --- a/kubernetes/client/models/v1_status_cause.py +++ b/kubernetes/client/models/v1_status_cause.py @@ -26,72 +26,12 @@ from typing import TYPE_CHECKING -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatusCause(BaseModel): diff --git a/kubernetes/client/models/v1_status_details.py b/kubernetes/client/models/v1_status_details.py index 7983ba75cc..c29486c66e 100644 --- a/kubernetes/client/models/v1_status_details.py +++ b/kubernetes/client/models/v1_status_details.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StatusDetails(BaseModel): diff --git a/kubernetes/client/models/v1_storage_class.py b/kubernetes/client/models/v1_storage_class.py index 4293fbcce3..0af0f7c76c 100644 --- a/kubernetes/client/models/v1_storage_class.py +++ b/kubernetes/client/models/v1_storage_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageClass(BaseModel): diff --git a/kubernetes/client/models/v1_storage_class_list.py b/kubernetes/client/models/v1_storage_class_list.py index 5982e166c2..685c7a3a38 100644 --- a/kubernetes/client/models/v1_storage_class_list.py +++ b/kubernetes/client/models/v1_storage_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageClassList(BaseModel): diff --git a/kubernetes/client/models/v1_storage_health.py b/kubernetes/client/models/v1_storage_health.py index 90f753e2d9..1f6348bb7d 100644 --- a/kubernetes/client/models/v1_storage_health.py +++ b/kubernetes/client/models/v1_storage_health.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageHealth(BaseModel): diff --git a/kubernetes/client/models/v1_storage_health_condition.py b/kubernetes/client/models/v1_storage_health_condition.py index bb1e294909..e4becb19b4 100644 --- a/kubernetes/client/models/v1_storage_health_condition.py +++ b/kubernetes/client/models/v1_storage_health_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageHealthCondition(BaseModel): diff --git a/kubernetes/client/models/v1_storage_os_persistent_volume_source.py b/kubernetes/client/models/v1_storage_os_persistent_volume_source.py index 054af3457f..7ccc4a684b 100644 --- a/kubernetes/client/models/v1_storage_os_persistent_volume_source.py +++ b/kubernetes/client/models/v1_storage_os_persistent_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageOSPersistentVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_storage_os_volume_source.py b/kubernetes/client/models/v1_storage_os_volume_source.py index fe73066fd3..770125d8ee 100644 --- a/kubernetes/client/models/v1_storage_os_volume_source.py +++ b/kubernetes/client/models/v1_storage_os_volume_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageOSVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_storage_version_migration.py b/kubernetes/client/models/v1_storage_version_migration.py index 8153f4fb1f..c9bab44c17 100644 --- a/kubernetes/client/models/v1_storage_version_migration.py +++ b/kubernetes/client/models/v1_storage_version_migration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigration(BaseModel): diff --git a/kubernetes/client/models/v1_storage_version_migration_list.py b/kubernetes/client/models/v1_storage_version_migration_list.py index 685d21ee5b..97c519f908 100644 --- a/kubernetes/client/models/v1_storage_version_migration_list.py +++ b/kubernetes/client/models/v1_storage_version_migration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationList(BaseModel): diff --git a/kubernetes/client/models/v1_storage_version_migration_spec.py b/kubernetes/client/models/v1_storage_version_migration_spec.py index 9431f6fd08..5526441f9c 100644 --- a/kubernetes/client/models/v1_storage_version_migration_spec.py +++ b/kubernetes/client/models/v1_storage_version_migration_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationSpec(BaseModel): diff --git a/kubernetes/client/models/v1_storage_version_migration_status.py b/kubernetes/client/models/v1_storage_version_migration_status.py index 233c8e5f85..f565ba2f9f 100644 --- a/kubernetes/client/models/v1_storage_version_migration_status.py +++ b/kubernetes/client/models/v1_storage_version_migration_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1StorageVersionMigrationStatus(BaseModel): diff --git a/kubernetes/client/models/v1_subject_access_review.py b/kubernetes/client/models/v1_subject_access_review.py index 547dcc3bdb..38645c9255 100644 --- a/kubernetes/client/models/v1_subject_access_review.py +++ b/kubernetes/client/models/v1_subject_access_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReview(BaseModel): diff --git a/kubernetes/client/models/v1_subject_access_review_spec.py b/kubernetes/client/models/v1_subject_access_review_spec.py index 7966993ded..183b264024 100644 --- a/kubernetes/client/models/v1_subject_access_review_spec.py +++ b/kubernetes/client/models/v1_subject_access_review_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReviewSpec(BaseModel): diff --git a/kubernetes/client/models/v1_subject_access_review_status.py b/kubernetes/client/models/v1_subject_access_review_status.py index 659acc35a8..7b0d26fbdc 100644 --- a/kubernetes/client/models/v1_subject_access_review_status.py +++ b/kubernetes/client/models/v1_subject_access_review_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectAccessReviewStatus(BaseModel): diff --git a/kubernetes/client/models/v1_subject_rules_review_status.py b/kubernetes/client/models/v1_subject_rules_review_status.py index b1444b16f2..608bfd7a4a 100644 --- a/kubernetes/client/models/v1_subject_rules_review_status.py +++ b/kubernetes/client/models/v1_subject_rules_review_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SubjectRulesReviewStatus(BaseModel): diff --git a/kubernetes/client/models/v1_success_policy.py b/kubernetes/client/models/v1_success_policy.py index ed2fc8e000..e81db9eeb4 100644 --- a/kubernetes/client/models/v1_success_policy.py +++ b/kubernetes/client/models/v1_success_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SuccessPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_success_policy_rule.py b/kubernetes/client/models/v1_success_policy_rule.py index e6fc5f0879..07ab3c4258 100644 --- a/kubernetes/client/models/v1_success_policy_rule.py +++ b/kubernetes/client/models/v1_success_policy_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1SuccessPolicyRule(BaseModel): diff --git a/kubernetes/client/models/v1_sysctl.py b/kubernetes/client/models/v1_sysctl.py index dabc77a8a4..b0a630f852 100644 --- a/kubernetes/client/models/v1_sysctl.py +++ b/kubernetes/client/models/v1_sysctl.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Sysctl(BaseModel): diff --git a/kubernetes/client/models/v1_taint.py b/kubernetes/client/models/v1_taint.py index be641e0a12..8f623728f9 100644 --- a/kubernetes/client/models/v1_taint.py +++ b/kubernetes/client/models/v1_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Taint(BaseModel): diff --git a/kubernetes/client/models/v1_tcp_socket_action.py b/kubernetes/client/models/v1_tcp_socket_action.py index 27fc2ef574..8ca6d66c95 100644 --- a/kubernetes/client/models/v1_tcp_socket_action.py +++ b/kubernetes/client/models/v1_tcp_socket_action.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TCPSocketAction(BaseModel): diff --git a/kubernetes/client/models/v1_token_request_spec.py b/kubernetes/client/models/v1_token_request_spec.py index 6f5a9c6633..f20a3a5b85 100644 --- a/kubernetes/client/models/v1_token_request_spec.py +++ b/kubernetes/client/models/v1_token_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1_token_request_status.py b/kubernetes/client/models/v1_token_request_status.py index 5eb121fe1e..981fee41ef 100644 --- a/kubernetes/client/models/v1_token_request_status.py +++ b/kubernetes/client/models/v1_token_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1_token_review.py b/kubernetes/client/models/v1_token_review.py index e7f4b64bfb..a9b97f4c68 100644 --- a/kubernetes/client/models/v1_token_review.py +++ b/kubernetes/client/models/v1_token_review.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReview(BaseModel): diff --git a/kubernetes/client/models/v1_token_review_spec.py b/kubernetes/client/models/v1_token_review_spec.py index 924084c43c..14fd97bbdf 100644 --- a/kubernetes/client/models/v1_token_review_spec.py +++ b/kubernetes/client/models/v1_token_review_spec.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReviewSpec(BaseModel): diff --git a/kubernetes/client/models/v1_token_review_status.py b/kubernetes/client/models/v1_token_review_status.py index f0bbcb34f9..729a9b0454 100644 --- a/kubernetes/client/models/v1_token_review_status.py +++ b/kubernetes/client/models/v1_token_review_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TokenReviewStatus(BaseModel): diff --git a/kubernetes/client/models/v1_toleration.py b/kubernetes/client/models/v1_toleration.py index 54710b50c1..9e634aa625 100644 --- a/kubernetes/client/models/v1_toleration.py +++ b/kubernetes/client/models/v1_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Toleration(BaseModel): diff --git a/kubernetes/client/models/v1_topology_selector_label_requirement.py b/kubernetes/client/models/v1_topology_selector_label_requirement.py index d542bfcb3d..a9ad68439d 100644 --- a/kubernetes/client/models/v1_topology_selector_label_requirement.py +++ b/kubernetes/client/models/v1_topology_selector_label_requirement.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySelectorLabelRequirement(BaseModel): diff --git a/kubernetes/client/models/v1_topology_selector_term.py b/kubernetes/client/models/v1_topology_selector_term.py index 3e4527136e..2749303cdc 100644 --- a/kubernetes/client/models/v1_topology_selector_term.py +++ b/kubernetes/client/models/v1_topology_selector_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySelectorTerm(BaseModel): diff --git a/kubernetes/client/models/v1_topology_spread_constraint.py b/kubernetes/client/models/v1_topology_spread_constraint.py index 49c8651615..270dbbe77a 100644 --- a/kubernetes/client/models/v1_topology_spread_constraint.py +++ b/kubernetes/client/models/v1_topology_spread_constraint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TopologySpreadConstraint(BaseModel): diff --git a/kubernetes/client/models/v1_type_checking.py b/kubernetes/client/models/v1_type_checking.py index be7d146ae5..ae77bd0659 100644 --- a/kubernetes/client/models/v1_type_checking.py +++ b/kubernetes/client/models/v1_type_checking.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypeChecking(BaseModel): diff --git a/kubernetes/client/models/v1_typed_local_object_reference.py b/kubernetes/client/models/v1_typed_local_object_reference.py index d921eaf0e0..94fee8f754 100644 --- a/kubernetes/client/models/v1_typed_local_object_reference.py +++ b/kubernetes/client/models/v1_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_typed_object_reference.py b/kubernetes/client/models/v1_typed_object_reference.py index 83023a7754..d6cf1bea7f 100644 --- a/kubernetes/client/models/v1_typed_object_reference.py +++ b/kubernetes/client/models/v1_typed_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1TypedObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1_uncounted_terminated_pods.py b/kubernetes/client/models/v1_uncounted_terminated_pods.py index 0cca4b4e58..057c1d63e5 100644 --- a/kubernetes/client/models/v1_uncounted_terminated_pods.py +++ b/kubernetes/client/models/v1_uncounted_terminated_pods.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UncountedTerminatedPods(BaseModel): diff --git a/kubernetes/client/models/v1_user_info.py b/kubernetes/client/models/v1_user_info.py index 9c5f383db4..f3aeb2727e 100644 --- a/kubernetes/client/models/v1_user_info.py +++ b/kubernetes/client/models/v1_user_info.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UserInfo(BaseModel): diff --git a/kubernetes/client/models/v1_user_subject.py b/kubernetes/client/models/v1_user_subject.py index 482e2f182c..5fba7c5293 100644 --- a/kubernetes/client/models/v1_user_subject.py +++ b/kubernetes/client/models/v1_user_subject.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1UserSubject(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy.py b/kubernetes/client/models/v1_validating_admission_policy.py index e33c443bcb..1bdab44111 100644 --- a/kubernetes/client/models/v1_validating_admission_policy.py +++ b/kubernetes/client/models/v1_validating_admission_policy.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_binding.py b/kubernetes/client/models/v1_validating_admission_policy_binding.py index 1783e751a4..770aa45fba 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_binding.py +++ b/kubernetes/client/models/v1_validating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_binding_list.py b/kubernetes/client/models/v1_validating_admission_policy_binding_list.py index 2500842647..c2f0c2e532 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_binding_list.py +++ b/kubernetes/client/models/v1_validating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_binding_spec.py b/kubernetes/client/models/v1_validating_admission_policy_binding_spec.py index 538bd72451..15f9944eb3 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_binding_spec.py +++ b/kubernetes/client/models/v1_validating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_list.py b/kubernetes/client/models/v1_validating_admission_policy_list.py index 46cf935b4c..4f6e39ced4 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_list.py +++ b/kubernetes/client/models/v1_validating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_spec.py b/kubernetes/client/models/v1_validating_admission_policy_spec.py index c2c7cf143f..26dd236038 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_spec.py +++ b/kubernetes/client/models/v1_validating_admission_policy_spec.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/client/models/v1_validating_admission_policy_status.py b/kubernetes/client/models/v1_validating_admission_policy_status.py index d5b7570a54..b551784d8e 100644 --- a/kubernetes/client/models/v1_validating_admission_policy_status.py +++ b/kubernetes/client/models/v1_validating_admission_policy_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingAdmissionPolicyStatus(BaseModel): diff --git a/kubernetes/client/models/v1_validating_webhook.py b/kubernetes/client/models/v1_validating_webhook.py index 7c26f1a735..3b4f57a64d 100644 --- a/kubernetes/client/models/v1_validating_webhook.py +++ b/kubernetes/client/models/v1_validating_webhook.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhook(BaseModel): diff --git a/kubernetes/client/models/v1_validating_webhook_configuration.py b/kubernetes/client/models/v1_validating_webhook_configuration.py index d665cd405b..4dd869b5f0 100644 --- a/kubernetes/client/models/v1_validating_webhook_configuration.py +++ b/kubernetes/client/models/v1_validating_webhook_configuration.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhookConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1_validating_webhook_configuration_list.py b/kubernetes/client/models/v1_validating_webhook_configuration_list.py index fcaf5088cb..afee00f128 100644 --- a/kubernetes/client/models/v1_validating_webhook_configuration_list.py +++ b/kubernetes/client/models/v1_validating_webhook_configuration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidatingWebhookConfigurationList(BaseModel): diff --git a/kubernetes/client/models/v1_validation.py b/kubernetes/client/models/v1_validation.py index fe1261dcde..05aad373e2 100644 --- a/kubernetes/client/models/v1_validation.py +++ b/kubernetes/client/models/v1_validation.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Validation(BaseModel): diff --git a/kubernetes/client/models/v1_validation_rule.py b/kubernetes/client/models/v1_validation_rule.py index 8b8ada19ce..5e66e51205 100644 --- a/kubernetes/client/models/v1_validation_rule.py +++ b/kubernetes/client/models/v1_validation_rule.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1ValidationRule(BaseModel): diff --git a/kubernetes/client/models/v1_variable.py b/kubernetes/client/models/v1_variable.py index 85afec93de..3736e2965b 100644 --- a/kubernetes/client/models/v1_variable.py +++ b/kubernetes/client/models/v1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Variable(BaseModel): diff --git a/kubernetes/client/models/v1_volume.py b/kubernetes/client/models/v1_volume.py index 12fffe894e..18a6ce32d6 100644 --- a/kubernetes/client/models/v1_volume.py +++ b/kubernetes/client/models/v1_volume.py @@ -55,72 +55,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1Volume(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attachment.py b/kubernetes/client/models/v1_volume_attachment.py index 9e9f3854d8..406b1e85b7 100644 --- a/kubernetes/client/models/v1_volume_attachment.py +++ b/kubernetes/client/models/v1_volume_attachment.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachment(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attachment_list.py b/kubernetes/client/models/v1_volume_attachment_list.py index f0c369ec03..b2746d3496 100644 --- a/kubernetes/client/models/v1_volume_attachment_list.py +++ b/kubernetes/client/models/v1_volume_attachment_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentList(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attachment_source.py b/kubernetes/client/models/v1_volume_attachment_source.py index 685cd875a0..7c7b5f517f 100644 --- a/kubernetes/client/models/v1_volume_attachment_source.py +++ b/kubernetes/client/models/v1_volume_attachment_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentSource(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attachment_spec.py b/kubernetes/client/models/v1_volume_attachment_spec.py index 90fbc81f1b..1e3af59a33 100644 --- a/kubernetes/client/models/v1_volume_attachment_spec.py +++ b/kubernetes/client/models/v1_volume_attachment_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentSpec(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attachment_status.py b/kubernetes/client/models/v1_volume_attachment_status.py index 59f62a2c04..3c84a6c27e 100644 --- a/kubernetes/client/models/v1_volume_attachment_status.py +++ b/kubernetes/client/models/v1_volume_attachment_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttachmentStatus(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attributes_class.py b/kubernetes/client/models/v1_volume_attributes_class.py index 044a4528e0..4946383f75 100644 --- a/kubernetes/client/models/v1_volume_attributes_class.py +++ b/kubernetes/client/models/v1_volume_attributes_class.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttributesClass(BaseModel): diff --git a/kubernetes/client/models/v1_volume_attributes_class_list.py b/kubernetes/client/models/v1_volume_attributes_class_list.py index 7e6c3f3282..cece14a721 100644 --- a/kubernetes/client/models/v1_volume_attributes_class_list.py +++ b/kubernetes/client/models/v1_volume_attributes_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeAttributesClassList(BaseModel): diff --git a/kubernetes/client/models/v1_volume_device.py b/kubernetes/client/models/v1_volume_device.py index 2b27569ddc..f7cd478bb9 100644 --- a/kubernetes/client/models/v1_volume_device.py +++ b/kubernetes/client/models/v1_volume_device.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeDevice(BaseModel): diff --git a/kubernetes/client/models/v1_volume_error.py b/kubernetes/client/models/v1_volume_error.py index b56518a667..e16df9660e 100644 --- a/kubernetes/client/models/v1_volume_error.py +++ b/kubernetes/client/models/v1_volume_error.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeError(BaseModel): diff --git a/kubernetes/client/models/v1_volume_health_condition.py b/kubernetes/client/models/v1_volume_health_condition.py index b92cc17235..1a392ab433 100644 --- a/kubernetes/client/models/v1_volume_health_condition.py +++ b/kubernetes/client/models/v1_volume_health_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeHealthCondition(BaseModel): diff --git a/kubernetes/client/models/v1_volume_health_status.py b/kubernetes/client/models/v1_volume_health_status.py index 1f6292e463..48250264c6 100644 --- a/kubernetes/client/models/v1_volume_health_status.py +++ b/kubernetes/client/models/v1_volume_health_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeHealthStatus(BaseModel): diff --git a/kubernetes/client/models/v1_volume_mount.py b/kubernetes/client/models/v1_volume_mount.py index 630f75986c..f08042083d 100644 --- a/kubernetes/client/models/v1_volume_mount.py +++ b/kubernetes/client/models/v1_volume_mount.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeMount(BaseModel): diff --git a/kubernetes/client/models/v1_volume_mount_status.py b/kubernetes/client/models/v1_volume_mount_status.py index c7553cdbcb..9bdfb075ce 100644 --- a/kubernetes/client/models/v1_volume_mount_status.py +++ b/kubernetes/client/models/v1_volume_mount_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeMountStatus(BaseModel): diff --git a/kubernetes/client/models/v1_volume_node_affinity.py b/kubernetes/client/models/v1_volume_node_affinity.py index 76be2271dd..754b76cfd3 100644 --- a/kubernetes/client/models/v1_volume_node_affinity.py +++ b/kubernetes/client/models/v1_volume_node_affinity.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeNodeAffinity(BaseModel): diff --git a/kubernetes/client/models/v1_volume_node_resources.py b/kubernetes/client/models/v1_volume_node_resources.py index 02188efbe8..414b9b0caf 100644 --- a/kubernetes/client/models/v1_volume_node_resources.py +++ b/kubernetes/client/models/v1_volume_node_resources.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeNodeResources(BaseModel): diff --git a/kubernetes/client/models/v1_volume_projection.py b/kubernetes/client/models/v1_volume_projection.py index 58b34c18fb..5d1e6ef42e 100644 --- a/kubernetes/client/models/v1_volume_projection.py +++ b/kubernetes/client/models/v1_volume_projection.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeProjection(BaseModel): diff --git a/kubernetes/client/models/v1_volume_resource_requirements.py b/kubernetes/client/models/v1_volume_resource_requirements.py index 6c04018d83..965f728820 100644 --- a/kubernetes/client/models/v1_volume_resource_requirements.py +++ b/kubernetes/client/models/v1_volume_resource_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeResourceRequirements(BaseModel): diff --git a/kubernetes/client/models/v1_volume_status.py b/kubernetes/client/models/v1_volume_status.py index eb26a3f488..c6783fed94 100644 --- a/kubernetes/client/models/v1_volume_status.py +++ b/kubernetes/client/models/v1_volume_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VolumeStatus(BaseModel): diff --git a/kubernetes/client/models/v1_vsphere_virtual_disk_volume_source.py b/kubernetes/client/models/v1_vsphere_virtual_disk_volume_source.py index 19d2ea360c..2835754b7f 100644 --- a/kubernetes/client/models/v1_vsphere_virtual_disk_volume_source.py +++ b/kubernetes/client/models/v1_vsphere_virtual_disk_volume_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1VsphereVirtualDiskVolumeSource(BaseModel): diff --git a/kubernetes/client/models/v1_watch_event.py b/kubernetes/client/models/v1_watch_event.py index 6b14f770c4..65b47047b6 100644 --- a/kubernetes/client/models/v1_watch_event.py +++ b/kubernetes/client/models/v1_watch_event.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WatchEvent(BaseModel): diff --git a/kubernetes/client/models/v1_webhook_conversion.py b/kubernetes/client/models/v1_webhook_conversion.py index b717c21aa2..1c006657bf 100644 --- a/kubernetes/client/models/v1_webhook_conversion.py +++ b/kubernetes/client/models/v1_webhook_conversion.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WebhookConversion(BaseModel): diff --git a/kubernetes/client/models/v1_weighted_pod_affinity_term.py b/kubernetes/client/models/v1_weighted_pod_affinity_term.py index eb51c89c7e..14850c2d75 100644 --- a/kubernetes/client/models/v1_weighted_pod_affinity_term.py +++ b/kubernetes/client/models/v1_weighted_pod_affinity_term.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WeightedPodAffinityTerm(BaseModel): diff --git a/kubernetes/client/models/v1_windows_security_context_options.py b/kubernetes/client/models/v1_windows_security_context_options.py index 1ec877ca90..b696ae1044 100644 --- a/kubernetes/client/models/v1_windows_security_context_options.py +++ b/kubernetes/client/models/v1_windows_security_context_options.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1WindowsSecurityContextOptions(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_apply_configuration.py b/kubernetes/client/models/v1alpha1_apply_configuration.py index 9e1e35dfd3..0f57873c6d 100644 --- a/kubernetes/client/models/v1alpha1_apply_configuration.py +++ b/kubernetes/client/models/v1alpha1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ApplyConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction.py b/kubernetes/client/models/v1alpha1_eviction.py index b44643ee4c..976e2ae790 100644 --- a/kubernetes/client/models/v1alpha1_eviction.py +++ b/kubernetes/client/models/v1alpha1_eviction.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Eviction(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_list.py b/kubernetes/client/models/v1alpha1_eviction_list.py index 0e070e7079..5fe6e91e05 100644 --- a/kubernetes/client/models/v1alpha1_eviction_list.py +++ b/kubernetes/client/models/v1alpha1_eviction_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionList(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_pod_reference.py b/kubernetes/client/models/v1alpha1_eviction_pod_reference.py index 5968fe2b9d..89587d2902 100644 --- a/kubernetes/client/models/v1alpha1_eviction_pod_reference.py +++ b/kubernetes/client/models/v1alpha1_eviction_pod_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionPodReference(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request.py b/kubernetes/client/models/v1alpha1_eviction_request.py index 3ab57a58a6..7cd4b6fd2f 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request.py +++ b/kubernetes/client/models/v1alpha1_eviction_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequest(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request_list.py b/kubernetes/client/models/v1alpha1_eviction_request_list.py index 58ffc9a0f3..2938d8b38e 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request_list.py +++ b/kubernetes/client/models/v1alpha1_eviction_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestList(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request_pod_reference.py b/kubernetes/client/models/v1alpha1_eviction_request_pod_reference.py index 572360589c..3f6a7f52b8 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request_pod_reference.py +++ b/kubernetes/client/models/v1alpha1_eviction_request_pod_reference.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestPodReference(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request_spec.py b/kubernetes/client/models/v1alpha1_eviction_request_spec.py index 5f9ab0e938..1100db9162 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request_spec.py +++ b/kubernetes/client/models/v1alpha1_eviction_request_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request_status.py b/kubernetes/client/models/v1alpha1_eviction_request_status.py index 259d70122a..5193d6add4 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request_status.py +++ b/kubernetes/client/models/v1alpha1_eviction_request_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_request_target.py b/kubernetes/client/models/v1alpha1_eviction_request_target.py index 7c35c920d0..7783614f3d 100644 --- a/kubernetes/client/models/v1alpha1_eviction_request_target.py +++ b/kubernetes/client/models/v1alpha1_eviction_request_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionRequestTarget(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_spec.py b/kubernetes/client/models/v1alpha1_eviction_spec.py index 1cb3eb8a9b..0f5e5667b5 100644 --- a/kubernetes/client/models/v1alpha1_eviction_spec.py +++ b/kubernetes/client/models/v1alpha1_eviction_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_status.py b/kubernetes/client/models/v1alpha1_eviction_status.py index 1f85b8944e..320e849971 100644 --- a/kubernetes/client/models/v1alpha1_eviction_status.py +++ b/kubernetes/client/models/v1alpha1_eviction_status.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_eviction_target.py b/kubernetes/client/models/v1alpha1_eviction_target.py index 103a87a2e9..2c87125feb 100644 --- a/kubernetes/client/models/v1alpha1_eviction_target.py +++ b/kubernetes/client/models/v1alpha1_eviction_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1EvictionTarget(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_json_patch.py b/kubernetes/client/models/v1alpha1_json_patch.py index 5a3b3d5a18..13157f49c9 100644 --- a/kubernetes/client/models/v1alpha1_json_patch.py +++ b/kubernetes/client/models/v1alpha1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1JSONPatch(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_match_condition.py b/kubernetes/client/models/v1alpha1_match_condition.py index c655fdf308..e516a4456e 100644 --- a/kubernetes/client/models/v1alpha1_match_condition.py +++ b/kubernetes/client/models/v1alpha1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MatchCondition(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_match_resources.py b/kubernetes/client/models/v1alpha1_match_resources.py index 9b0c86dd62..22c63073fc 100644 --- a/kubernetes/client/models/v1alpha1_match_resources.py +++ b/kubernetes/client/models/v1alpha1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MatchResources(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy.py index e28a6d3fa5..3dc9a419b4 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding.py index e0ce8d92e9..5e69f7cc1a 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_list.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_list.py index fd73e25b40..8b9b398118 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_list.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_spec.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_spec.py index 387f84e0f7..17b0dfbc4f 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy_list.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy_list.py index 7b88581064..0534c5fe4f 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy_list.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutating_admission_policy_spec.py b/kubernetes/client/models/v1alpha1_mutating_admission_policy_spec.py index 06dd95a81f..674e4c1e40 100644 --- a/kubernetes/client/models/v1alpha1_mutating_admission_policy_spec.py +++ b/kubernetes/client/models/v1alpha1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_mutation.py b/kubernetes/client/models/v1alpha1_mutation.py index 7b671267b1..7fd1659cd9 100644 --- a/kubernetes/client/models/v1alpha1_mutation.py +++ b/kubernetes/client/models/v1alpha1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Mutation(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_named_rule_with_operations.py b/kubernetes/client/models/v1alpha1_named_rule_with_operations.py index fb89670257..6ec8adc362 100644 --- a/kubernetes/client/models/v1alpha1_named_rule_with_operations.py +++ b/kubernetes/client/models/v1alpha1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_param_kind.py b/kubernetes/client/models/v1alpha1_param_kind.py index 7f0462813c..bbec9bc5a8 100644 --- a/kubernetes/client/models/v1alpha1_param_kind.py +++ b/kubernetes/client/models/v1alpha1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ParamKind(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_param_ref.py b/kubernetes/client/models/v1alpha1_param_ref.py index 53c7e752e9..766c0f8972 100644 --- a/kubernetes/client/models/v1alpha1_param_ref.py +++ b/kubernetes/client/models/v1alpha1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ParamRef(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_requester.py b/kubernetes/client/models/v1alpha1_requester.py index d0f68ab078..ad427b80d7 100644 --- a/kubernetes/client/models/v1alpha1_requester.py +++ b/kubernetes/client/models/v1alpha1_requester.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Requester(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_responder_status.py b/kubernetes/client/models/v1alpha1_responder_status.py index 7ba7b7ed55..17abe3c806 100644 --- a/kubernetes/client/models/v1alpha1_responder_status.py +++ b/kubernetes/client/models/v1alpha1_responder_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ResponderStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_server_storage_version.py b/kubernetes/client/models/v1alpha1_server_storage_version.py index 903fc9ddc6..3500646add 100644 --- a/kubernetes/client/models/v1alpha1_server_storage_version.py +++ b/kubernetes/client/models/v1alpha1_server_storage_version.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1ServerStorageVersion(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_storage_version.py b/kubernetes/client/models/v1alpha1_storage_version.py index 2c0cfa71f5..c64475570d 100644 --- a/kubernetes/client/models/v1alpha1_storage_version.py +++ b/kubernetes/client/models/v1alpha1_storage_version.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersion(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_storage_version_condition.py b/kubernetes/client/models/v1alpha1_storage_version_condition.py index f2d0575fba..9697cce40a 100644 --- a/kubernetes/client/models/v1alpha1_storage_version_condition.py +++ b/kubernetes/client/models/v1alpha1_storage_version_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionCondition(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_storage_version_list.py b/kubernetes/client/models/v1alpha1_storage_version_list.py index 434981eb7f..8df7bb6721 100644 --- a/kubernetes/client/models/v1alpha1_storage_version_list.py +++ b/kubernetes/client/models/v1alpha1_storage_version_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionList(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_storage_version_status.py b/kubernetes/client/models/v1alpha1_storage_version_status.py index ef2f5c8b45..25821a9a87 100644 --- a/kubernetes/client/models/v1alpha1_storage_version_status.py +++ b/kubernetes/client/models/v1alpha1_storage_version_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1StorageVersionStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_target_responder.py b/kubernetes/client/models/v1alpha1_target_responder.py index 60a2562a80..a20cb224eb 100644 --- a/kubernetes/client/models/v1alpha1_target_responder.py +++ b/kubernetes/client/models/v1alpha1_target_responder.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1TargetResponder(BaseModel): diff --git a/kubernetes/client/models/v1alpha1_variable.py b/kubernetes/client/models/v1alpha1_variable.py index eb7fbcce4b..fccf1a7702 100644 --- a/kubernetes/client/models/v1alpha1_variable.py +++ b/kubernetes/client/models/v1alpha1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha1Variable(BaseModel): diff --git a/kubernetes/client/models/v1alpha2_lease_candidate.py b/kubernetes/client/models/v1alpha2_lease_candidate.py index 0042d293fb..54650ff605 100644 --- a/kubernetes/client/models/v1alpha2_lease_candidate.py +++ b/kubernetes/client/models/v1alpha2_lease_candidate.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidate(BaseModel): diff --git a/kubernetes/client/models/v1alpha2_lease_candidate_list.py b/kubernetes/client/models/v1alpha2_lease_candidate_list.py index 13c0658298..13772d2bfc 100644 --- a/kubernetes/client/models/v1alpha2_lease_candidate_list.py +++ b/kubernetes/client/models/v1alpha2_lease_candidate_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidateList(BaseModel): diff --git a/kubernetes/client/models/v1alpha2_lease_candidate_spec.py b/kubernetes/client/models/v1alpha2_lease_candidate_spec.py index 921b5b6ac7..c1d41b5eca 100644 --- a/kubernetes/client/models/v1alpha2_lease_candidate_spec.py +++ b/kubernetes/client/models/v1alpha2_lease_candidate_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha2LeaseCandidateSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_disruption_mode.py b/kubernetes/client/models/v1alpha3_composite_disruption_mode.py index 395543ca17..720ba3bcf1 100644 --- a/kubernetes/client/models/v1alpha3_composite_disruption_mode.py +++ b/kubernetes/client/models/v1alpha3_composite_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositeDisruptionMode(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_gang_scheduling_policy.py b/kubernetes/client/models/v1alpha3_composite_gang_scheduling_policy.py index b19cc716bf..65e0ef8db1 100644 --- a/kubernetes/client/models/v1alpha3_composite_gang_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_composite_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositeGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group.py b/kubernetes/client/models/v1alpha3_composite_pod_group.py index b464f50bc9..a62c038404 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroup(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_list.py b/kubernetes/client/models/v1alpha3_composite_pod_group_list.py index a4918cae50..5be8851617 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_list.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupList(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py b/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py index 3415a007b8..9f75f387ae 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_policy.py b/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_policy.py index a135a76d2f..0bbb4c36aa 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_spec.py b/kubernetes/client/models/v1alpha3_composite_pod_group_spec.py index d833176d3b..bb3f5cfd69 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_spec.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_status.py b/kubernetes/client/models/v1alpha3_composite_pod_group_status.py index 826f1f820d..3f8044e9cd 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_status.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_composite_pod_group_template.py b/kubernetes/client/models/v1alpha3_composite_pod_group_template.py index fc8bbb6444..0a65e0a4ea 100644 --- a/kubernetes/client/models/v1alpha3_composite_pod_group_template.py +++ b/kubernetes/client/models/v1alpha3_composite_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3CompositePodGroupTemplate(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint.py b/kubernetes/client/models/v1alpha3_device_taint.py index 89a152458d..94b5f79d14 100644 --- a/kubernetes/client/models/v1alpha3_device_taint.py +++ b/kubernetes/client/models/v1alpha3_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaint(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint_rule.py b/kubernetes/client/models/v1alpha3_device_taint_rule.py index 0d11994685..8425e21025 100644 --- a/kubernetes/client/models/v1alpha3_device_taint_rule.py +++ b/kubernetes/client/models/v1alpha3_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRule(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint_rule_list.py b/kubernetes/client/models/v1alpha3_device_taint_rule_list.py index a34238df52..968de64450 100644 --- a/kubernetes/client/models/v1alpha3_device_taint_rule_list.py +++ b/kubernetes/client/models/v1alpha3_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint_rule_spec.py b/kubernetes/client/models/v1alpha3_device_taint_rule_spec.py index 1ab5166136..dabfc06fd2 100644 --- a/kubernetes/client/models/v1alpha3_device_taint_rule_spec.py +++ b/kubernetes/client/models/v1alpha3_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint_rule_status.py b/kubernetes/client/models/v1alpha3_device_taint_rule_status.py index 18c005bdff..533bb3d318 100644 --- a/kubernetes/client/models/v1alpha3_device_taint_rule_status.py +++ b/kubernetes/client/models/v1alpha3_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_device_taint_selector.py b/kubernetes/client/models/v1alpha3_device_taint_selector.py index 78bcc9a8fa..955da1f3f8 100644 --- a/kubernetes/client/models/v1alpha3_device_taint_selector.py +++ b/kubernetes/client/models/v1alpha3_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DeviceTaintSelector(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_disruption_mode.py b/kubernetes/client/models/v1alpha3_disruption_mode.py index f72f9664af..eb0b40c470 100644 --- a/kubernetes/client/models/v1alpha3_disruption_mode.py +++ b/kubernetes/client/models/v1alpha3_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3DisruptionMode(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_gang_scheduling_policy.py b/kubernetes/client/models/v1alpha3_gang_scheduling_policy.py index 120249017d..8be86a07da 100644 --- a/kubernetes/client/models/v1alpha3_gang_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3GangSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_partition_type_status.py b/kubernetes/client/models/v1alpha3_partition_type_status.py index 7c9dbd1aa8..626626e38e 100644 --- a/kubernetes/client/models/v1alpha3_partition_type_status.py +++ b/kubernetes/client/models/v1alpha3_partition_type_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PartitionTypeStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group.py b/kubernetes/client/models/v1alpha3_pod_group.py index b0a8df4286..ca1843e928 100644 --- a/kubernetes/client/models/v1alpha3_pod_group.py +++ b/kubernetes/client/models/v1alpha3_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroup(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_list.py b/kubernetes/client/models/v1alpha3_pod_group_list.py index b62a7d6602..bfa69a6770 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_list.py +++ b/kubernetes/client/models/v1alpha3_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupList(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_resource_claim.py b/kubernetes/client/models/v1alpha3_pod_group_resource_claim.py index cbce33ffab..dc50b3fbf7 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_resource_claim.py +++ b/kubernetes/client/models/v1alpha3_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_resource_claim_status.py b/kubernetes/client/models/v1alpha3_pod_group_resource_claim_status.py index 0efbbdc597..fae52bf18b 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_resource_claim_status.py +++ b/kubernetes/client/models/v1alpha3_pod_group_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_scheduling_constraints.py b/kubernetes/client/models/v1alpha3_pod_group_scheduling_constraints.py index 831e282c66..06cb428cd5 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_scheduling_constraints.py +++ b/kubernetes/client/models/v1alpha3_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_scheduling_policy.py b/kubernetes/client/models/v1alpha3_pod_group_scheduling_policy.py index a901645136..5bd65bf14d 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_spec.py b/kubernetes/client/models/v1alpha3_pod_group_spec.py index 460b83a9fa..f9ed2d3070 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_spec.py +++ b/kubernetes/client/models/v1alpha3_pod_group_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_status.py b/kubernetes/client/models/v1alpha3_pod_group_status.py index be778fcfc7..b8f4677a42 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_status.py +++ b/kubernetes/client/models/v1alpha3_pod_group_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pod_group_template.py b/kubernetes/client/models/v1alpha3_pod_group_template.py index 5ac24cb0d0..1c6812070f 100644 --- a/kubernetes/client/models/v1alpha3_pod_group_template.py +++ b/kubernetes/client/models/v1alpha3_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PodGroupTemplate(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_pool_status.py b/kubernetes/client/models/v1alpha3_pool_status.py index 36b709e41e..475be2e850 100644 --- a/kubernetes/client/models/v1alpha3_pool_status.py +++ b/kubernetes/client/models/v1alpha3_pool_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3PoolStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_resource_pool_status_request.py b/kubernetes/client/models/v1alpha3_resource_pool_status_request.py index 9130e504a5..e0edd6f366 100644 --- a/kubernetes/client/models/v1alpha3_resource_pool_status_request.py +++ b/kubernetes/client/models/v1alpha3_resource_pool_status_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequest(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_resource_pool_status_request_list.py b/kubernetes/client/models/v1alpha3_resource_pool_status_request_list.py index 5f8bda6da2..ad06540754 100644 --- a/kubernetes/client/models/v1alpha3_resource_pool_status_request_list.py +++ b/kubernetes/client/models/v1alpha3_resource_pool_status_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestList(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_resource_pool_status_request_spec.py b/kubernetes/client/models/v1alpha3_resource_pool_status_request_spec.py index a8a5e1e6a3..e692caa52d 100644 --- a/kubernetes/client/models/v1alpha3_resource_pool_status_request_spec.py +++ b/kubernetes/client/models/v1alpha3_resource_pool_status_request_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_resource_pool_status_request_status.py b/kubernetes/client/models/v1alpha3_resource_pool_status_request_status.py index 23c1a93be4..88f143b70e 100644 --- a/kubernetes/client/models/v1alpha3_resource_pool_status_request_status.py +++ b/kubernetes/client/models/v1alpha3_resource_pool_status_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ResourcePoolStatusRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_shareable_capacity_status.py b/kubernetes/client/models/v1alpha3_shareable_capacity_status.py index eca187aa22..747f9e0d5b 100644 --- a/kubernetes/client/models/v1alpha3_shareable_capacity_status.py +++ b/kubernetes/client/models/v1alpha3_shareable_capacity_status.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ShareableCapacityStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_shareable_summary_status.py b/kubernetes/client/models/v1alpha3_shareable_summary_status.py index 95f8ae6a9e..9fce8b2841 100644 --- a/kubernetes/client/models/v1alpha3_shareable_summary_status.py +++ b/kubernetes/client/models/v1alpha3_shareable_summary_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3ShareableSummaryStatus(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_topology_constraint.py b/kubernetes/client/models/v1alpha3_topology_constraint.py index a4aa134adb..bd561325bd 100644 --- a/kubernetes/client/models/v1alpha3_topology_constraint.py +++ b/kubernetes/client/models/v1alpha3_topology_constraint.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3TopologyConstraint(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_typed_local_object_reference.py b/kubernetes/client/models/v1alpha3_typed_local_object_reference.py index 35138b5a4b..685e5cd385 100644 --- a/kubernetes/client/models/v1alpha3_typed_local_object_reference.py +++ b/kubernetes/client/models/v1alpha3_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload.py b/kubernetes/client/models/v1alpha3_workload.py index 9b1d73e5b8..d0eaad8531 100644 --- a/kubernetes/client/models/v1alpha3_workload.py +++ b/kubernetes/client/models/v1alpha3_workload.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3Workload(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_list.py b/kubernetes/client/models/v1alpha3_workload_list.py index b28223c4c0..e3b7cb4f39 100644 --- a/kubernetes/client/models/v1alpha3_workload_list.py +++ b/kubernetes/client/models/v1alpha3_workload_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadList(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_pod_group_disruption_mode.py b/kubernetes/client/models/v1alpha3_workload_pod_group_disruption_mode.py index 557d4b84f9..1d9491558e 100644 --- a/kubernetes/client/models/v1alpha3_workload_pod_group_disruption_mode.py +++ b/kubernetes/client/models/v1alpha3_workload_pod_group_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupDisruptionMode(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py b/kubernetes/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py index 9c29d59e3c..13ca9c97e7 100644 --- a/kubernetes/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_workload_pod_group_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_pod_group_resource_claim.py b/kubernetes/client/models/v1alpha3_workload_pod_group_resource_claim.py index b983a4c561..e78c82c43a 100644 --- a/kubernetes/client/models/v1alpha3_workload_pod_group_resource_claim.py +++ b/kubernetes/client/models/v1alpha3_workload_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py b/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py index 633e5a28f8..5c6eb9b453 100644 --- a/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py +++ b/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_policy.py b/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_policy.py index 7f5839c374..1172f93581 100644 --- a/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_policy.py +++ b/kubernetes/client/models/v1alpha3_workload_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadPodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_reference.py b/kubernetes/client/models/v1alpha3_workload_reference.py index eb786d9462..8242254de6 100644 --- a/kubernetes/client/models/v1alpha3_workload_reference.py +++ b/kubernetes/client/models/v1alpha3_workload_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadReference(BaseModel): diff --git a/kubernetes/client/models/v1alpha3_workload_spec.py b/kubernetes/client/models/v1alpha3_workload_spec.py index 7ee8eb7c79..5d6e1d6dd6 100644 --- a/kubernetes/client/models/v1alpha3_workload_spec.py +++ b/kubernetes/client/models/v1alpha3_workload_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1alpha3WorkloadSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_allocated_device_status.py b/kubernetes/client/models/v1beta1_allocated_device_status.py index f9bf88b271..5bbab4024c 100644 --- a/kubernetes/client/models/v1beta1_allocated_device_status.py +++ b/kubernetes/client/models/v1beta1_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_allocation_result.py b/kubernetes/client/models/v1beta1_allocation_result.py index 0ebec89802..09bd8fb1b4 100644 --- a/kubernetes/client/models/v1beta1_allocation_result.py +++ b/kubernetes/client/models/v1beta1_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1AllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta1_apply_configuration.py b/kubernetes/client/models/v1beta1_apply_configuration.py index 21dd6e1cc9..3d52137e19 100644 --- a/kubernetes/client/models/v1beta1_apply_configuration.py +++ b/kubernetes/client/models/v1beta1_apply_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ApplyConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_basic_device.py b/kubernetes/client/models/v1beta1_basic_device.py index f04d1ed4a8..8a065d1d06 100644 --- a/kubernetes/client/models/v1beta1_basic_device.py +++ b/kubernetes/client/models/v1beta1_basic_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1BasicDevice(BaseModel): diff --git a/kubernetes/client/models/v1beta1_capacity_request_policy.py b/kubernetes/client/models/v1beta1_capacity_request_policy.py index 251394bc81..6d1a7dbb4d 100644 --- a/kubernetes/client/models/v1beta1_capacity_request_policy.py +++ b/kubernetes/client/models/v1beta1_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_capacity_request_policy_range.py b/kubernetes/client/models/v1beta1_capacity_request_policy_range.py index e85a6838e2..46c1293fac 100644 --- a/kubernetes/client/models/v1beta1_capacity_request_policy_range.py +++ b/kubernetes/client/models/v1beta1_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/client/models/v1beta1_capacity_requirements.py b/kubernetes/client/models/v1beta1_capacity_requirements.py index 20f33aad50..69c58a9a30 100644 --- a/kubernetes/client/models/v1beta1_capacity_requirements.py +++ b/kubernetes/client/models/v1beta1_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CapacityRequirements(BaseModel): diff --git a/kubernetes/client/models/v1beta1_cel_device_selector.py b/kubernetes/client/models/v1beta1_cel_device_selector.py index 7ef8bb1815..7d7342a738 100644 --- a/kubernetes/client/models/v1beta1_cel_device_selector.py +++ b/kubernetes/client/models/v1beta1_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CELDeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1beta1_cluster_trust_bundle.py b/kubernetes/client/models/v1beta1_cluster_trust_bundle.py index 5113af8afa..74ee9f7957 100644 --- a/kubernetes/client/models/v1beta1_cluster_trust_bundle.py +++ b/kubernetes/client/models/v1beta1_cluster_trust_bundle.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundle(BaseModel): diff --git a/kubernetes/client/models/v1beta1_cluster_trust_bundle_list.py b/kubernetes/client/models/v1beta1_cluster_trust_bundle_list.py index d7d857bac3..ce51540fc6 100644 --- a/kubernetes/client/models/v1beta1_cluster_trust_bundle_list.py +++ b/kubernetes/client/models/v1beta1_cluster_trust_bundle_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundleList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_cluster_trust_bundle_spec.py b/kubernetes/client/models/v1beta1_cluster_trust_bundle_spec.py index c35343969f..fc25a1e878 100644 --- a/kubernetes/client/models/v1beta1_cluster_trust_bundle_spec.py +++ b/kubernetes/client/models/v1beta1_cluster_trust_bundle_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ClusterTrustBundleSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_composite_disruption_mode.py b/kubernetes/client/models/v1beta1_composite_disruption_mode.py index 8b60442961..9dc2bb0559 100644 --- a/kubernetes/client/models/v1beta1_composite_disruption_mode.py +++ b/kubernetes/client/models/v1beta1_composite_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositeDisruptionMode(BaseModel): diff --git a/kubernetes/client/models/v1beta1_composite_gang_scheduling_policy.py b/kubernetes/client/models/v1beta1_composite_gang_scheduling_policy.py index e283a3554d..7bab84827c 100644 --- a/kubernetes/client/models/v1beta1_composite_gang_scheduling_policy.py +++ b/kubernetes/client/models/v1beta1_composite_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositeGangSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_constraints.py b/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_constraints.py index 6f9179a4aa..7efa8c6ff5 100644 --- a/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_constraints.py +++ b/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_policy.py b/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_policy.py index d811d806ad..ba4b280deb 100644 --- a/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_policy.py +++ b/kubernetes/client/models/v1beta1_composite_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_composite_pod_group_template.py b/kubernetes/client/models/v1beta1_composite_pod_group_template.py index 61e06ec8e3..5b3e3ef2b9 100644 --- a/kubernetes/client/models/v1beta1_composite_pod_group_template.py +++ b/kubernetes/client/models/v1beta1_composite_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CompositePodGroupTemplate(BaseModel): diff --git a/kubernetes/client/models/v1beta1_counter.py b/kubernetes/client/models/v1beta1_counter.py index 8c84101fbb..f920e90dde 100644 --- a/kubernetes/client/models/v1beta1_counter.py +++ b/kubernetes/client/models/v1beta1_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Counter(BaseModel): diff --git a/kubernetes/client/models/v1beta1_counter_set.py b/kubernetes/client/models/v1beta1_counter_set.py index fd7747192b..4e6c7ce79e 100644 --- a/kubernetes/client/models/v1beta1_counter_set.py +++ b/kubernetes/client/models/v1beta1_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1CounterSet(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device.py b/kubernetes/client/models/v1beta1_device.py index 44c8fbc88c..7f1530b991 100644 --- a/kubernetes/client/models/v1beta1_device.py +++ b/kubernetes/client/models/v1beta1_device.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Device(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_allocation_configuration.py b/kubernetes/client/models/v1beta1_device_allocation_configuration.py index 6277425321..c0178124c6 100644 --- a/kubernetes/client/models/v1beta1_device_allocation_configuration.py +++ b/kubernetes/client/models/v1beta1_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_allocation_result.py b/kubernetes/client/models/v1beta1_device_allocation_result.py index e03b28f044..4cc6e12731 100644 --- a/kubernetes/client/models/v1beta1_device_allocation_result.py +++ b/kubernetes/client/models/v1beta1_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_attribute.py b/kubernetes/client/models/v1beta1_device_attribute.py index 1bdd422644..d20ef81843 100644 --- a/kubernetes/client/models/v1beta1_device_attribute.py +++ b/kubernetes/client/models/v1beta1_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceAttribute(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_capacity.py b/kubernetes/client/models/v1beta1_device_capacity.py index aec4fdadf5..78edd4eb22 100644 --- a/kubernetes/client/models/v1beta1_device_capacity.py +++ b/kubernetes/client/models/v1beta1_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceCapacity(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_claim.py b/kubernetes/client/models/v1beta1_device_claim.py index c15fa7875b..e554fcdcf4 100644 --- a/kubernetes/client/models/v1beta1_device_claim.py +++ b/kubernetes/client/models/v1beta1_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClaim(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_claim_configuration.py b/kubernetes/client/models/v1beta1_device_claim_configuration.py index 11ba44e2e1..05c467c846 100644 --- a/kubernetes/client/models/v1beta1_device_claim_configuration.py +++ b/kubernetes/client/models/v1beta1_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_class.py b/kubernetes/client/models/v1beta1_device_class.py index 18bf680964..90c5105e15 100644 --- a/kubernetes/client/models/v1beta1_device_class.py +++ b/kubernetes/client/models/v1beta1_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClass(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_class_configuration.py b/kubernetes/client/models/v1beta1_device_class_configuration.py index 5fe1578b9f..7fe9df7a3f 100644 --- a/kubernetes/client/models/v1beta1_device_class_configuration.py +++ b/kubernetes/client/models/v1beta1_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_class_list.py b/kubernetes/client/models/v1beta1_device_class_list.py index 5e6471c55f..608723ed0e 100644 --- a/kubernetes/client/models/v1beta1_device_class_list.py +++ b/kubernetes/client/models/v1beta1_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_class_spec.py b/kubernetes/client/models/v1beta1_device_class_spec.py index 7e1fc138b3..d34193802b 100644 --- a/kubernetes/client/models/v1beta1_device_class_spec.py +++ b/kubernetes/client/models/v1beta1_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceClassSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_constraint.py b/kubernetes/client/models/v1beta1_device_constraint.py index c5a0ca77e5..b1b0d8c75b 100644 --- a/kubernetes/client/models/v1beta1_device_constraint.py +++ b/kubernetes/client/models/v1beta1_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceConstraint(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_counter_consumption.py b/kubernetes/client/models/v1beta1_device_counter_consumption.py index 50a22247ba..ac2c2696df 100644 --- a/kubernetes/client/models/v1beta1_device_counter_consumption.py +++ b/kubernetes/client/models/v1beta1_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_derived_attribute.py b/kubernetes/client/models/v1beta1_device_derived_attribute.py index dc624e45ce..76f536268b 100644 --- a/kubernetes/client/models/v1beta1_device_derived_attribute.py +++ b/kubernetes/client/models/v1beta1_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_request.py b/kubernetes/client/models/v1beta1_device_request.py index f28ecb7a52..45f105bff3 100644 --- a/kubernetes/client/models/v1beta1_device_request.py +++ b/kubernetes/client/models/v1beta1_device_request.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_request_allocation_result.py b/kubernetes/client/models/v1beta1_device_request_allocation_result.py index 80542bd28d..0bf0a60510 100644 --- a/kubernetes/client/models/v1beta1_device_request_allocation_result.py +++ b/kubernetes/client/models/v1beta1_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_selector.py b/kubernetes/client/models/v1beta1_device_selector.py index fb6693f314..28e8e0e452 100644 --- a/kubernetes/client/models/v1beta1_device_selector.py +++ b/kubernetes/client/models/v1beta1_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_sub_request.py b/kubernetes/client/models/v1beta1_device_sub_request.py index 79347c3954..b0b6d1e1c5 100644 --- a/kubernetes/client/models/v1beta1_device_sub_request.py +++ b/kubernetes/client/models/v1beta1_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceSubRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_taint.py b/kubernetes/client/models/v1beta1_device_taint.py index 6fdc0e16ec..211fa4db07 100644 --- a/kubernetes/client/models/v1beta1_device_taint.py +++ b/kubernetes/client/models/v1beta1_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceTaint(BaseModel): diff --git a/kubernetes/client/models/v1beta1_device_toleration.py b/kubernetes/client/models/v1beta1_device_toleration.py index 1e7c1a5003..d5d8db1c9f 100644 --- a/kubernetes/client/models/v1beta1_device_toleration.py +++ b/kubernetes/client/models/v1beta1_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DeviceToleration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_disruption_mode.py b/kubernetes/client/models/v1beta1_disruption_mode.py index a396c7971a..78a1acadda 100644 --- a/kubernetes/client/models/v1beta1_disruption_mode.py +++ b/kubernetes/client/models/v1beta1_disruption_mode.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1DisruptionMode(BaseModel): diff --git a/kubernetes/client/models/v1beta1_gang_scheduling_policy.py b/kubernetes/client/models/v1beta1_gang_scheduling_policy.py index bdb153abe0..0119e2c01b 100644 --- a/kubernetes/client/models/v1beta1_gang_scheduling_policy.py +++ b/kubernetes/client/models/v1beta1_gang_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1GangSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_json_patch.py b/kubernetes/client/models/v1beta1_json_patch.py index bf23cd7e21..eee6c7bfef 100644 --- a/kubernetes/client/models/v1beta1_json_patch.py +++ b/kubernetes/client/models/v1beta1_json_patch.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1JSONPatch(BaseModel): diff --git a/kubernetes/client/models/v1beta1_lease_candidate.py b/kubernetes/client/models/v1beta1_lease_candidate.py index d0cd4a38ad..6e039c155e 100644 --- a/kubernetes/client/models/v1beta1_lease_candidate.py +++ b/kubernetes/client/models/v1beta1_lease_candidate.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidate(BaseModel): diff --git a/kubernetes/client/models/v1beta1_lease_candidate_list.py b/kubernetes/client/models/v1beta1_lease_candidate_list.py index ea7d6060e4..87503a35f8 100644 --- a/kubernetes/client/models/v1beta1_lease_candidate_list.py +++ b/kubernetes/client/models/v1beta1_lease_candidate_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidateList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_lease_candidate_spec.py b/kubernetes/client/models/v1beta1_lease_candidate_spec.py index deff7e1e97..b3671f3501 100644 --- a/kubernetes/client/models/v1beta1_lease_candidate_spec.py +++ b/kubernetes/client/models/v1beta1_lease_candidate_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1LeaseCandidateSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_match_condition.py b/kubernetes/client/models/v1beta1_match_condition.py index 41a83a76e0..6c610d6af7 100644 --- a/kubernetes/client/models/v1beta1_match_condition.py +++ b/kubernetes/client/models/v1beta1_match_condition.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MatchCondition(BaseModel): diff --git a/kubernetes/client/models/v1beta1_match_resources.py b/kubernetes/client/models/v1beta1_match_resources.py index 5c4dcf7abc..9af5cee165 100644 --- a/kubernetes/client/models/v1beta1_match_resources.py +++ b/kubernetes/client/models/v1beta1_match_resources.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MatchResources(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy.py b/kubernetes/client/models/v1beta1_mutating_admission_policy.py index a80983db48..9b107b0dc2 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding.py b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding.py index 9330bcd3b4..f38ffece7c 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBinding(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_list.py b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_list.py index 7cff8ed2f9..f0a641d384 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_list.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBindingList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_spec.py b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_spec.py index ef6eb20f69..ab4992a858 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_spec.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy_binding_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyBindingSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy_list.py b/kubernetes/client/models/v1beta1_mutating_admission_policy_list.py index 19d0fd7d5b..86d3e1c149 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy_list.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicyList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutating_admission_policy_spec.py b/kubernetes/client/models/v1beta1_mutating_admission_policy_spec.py index 35d90b08cf..d2a41ed46c 100644 --- a/kubernetes/client/models/v1beta1_mutating_admission_policy_spec.py +++ b/kubernetes/client/models/v1beta1_mutating_admission_policy_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1MutatingAdmissionPolicySpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_mutation.py b/kubernetes/client/models/v1beta1_mutation.py index d4677722bf..be17c04f30 100644 --- a/kubernetes/client/models/v1beta1_mutation.py +++ b/kubernetes/client/models/v1beta1_mutation.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Mutation(BaseModel): diff --git a/kubernetes/client/models/v1beta1_named_rule_with_operations.py b/kubernetes/client/models/v1beta1_named_rule_with_operations.py index 57ba13d150..fa9f33164f 100644 --- a/kubernetes/client/models/v1beta1_named_rule_with_operations.py +++ b/kubernetes/client/models/v1beta1_named_rule_with_operations.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NamedRuleWithOperations(BaseModel): diff --git a/kubernetes/client/models/v1beta1_network_device_data.py b/kubernetes/client/models/v1beta1_network_device_data.py index 7e345bb780..ae56f96352 100644 --- a/kubernetes/client/models/v1beta1_network_device_data.py +++ b/kubernetes/client/models/v1beta1_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NetworkDeviceData(BaseModel): diff --git a/kubernetes/client/models/v1beta1_node_allocatable_mapping.py b/kubernetes/client/models/v1beta1_node_allocatable_mapping.py index a74fe9a6c4..0995f9cdb8 100644 --- a/kubernetes/client/models/v1beta1_node_allocatable_mapping.py +++ b/kubernetes/client/models/v1beta1_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/client/models/v1beta1_node_allocatable_overhead.py b/kubernetes/client/models/v1beta1_node_allocatable_overhead.py index 80fe64b5f1..57c68ab6ee 100644 --- a/kubernetes/client/models/v1beta1_node_allocatable_overhead.py +++ b/kubernetes/client/models/v1beta1_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/client/models/v1beta1_node_allocatable_resource.py b/kubernetes/client/models/v1beta1_node_allocatable_resource.py index 43a7c48d26..98b8f76073 100644 --- a/kubernetes/client/models/v1beta1_node_allocatable_resource.py +++ b/kubernetes/client/models/v1beta1_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1NodeAllocatableResource(BaseModel): diff --git a/kubernetes/client/models/v1beta1_opaque_device_configuration.py b/kubernetes/client/models/v1beta1_opaque_device_configuration.py index b2aaf6d194..b6aadfa5be 100644 --- a/kubernetes/client/models/v1beta1_opaque_device_configuration.py +++ b/kubernetes/client/models/v1beta1_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_param_kind.py b/kubernetes/client/models/v1beta1_param_kind.py index f69cf31720..3843df5bfe 100644 --- a/kubernetes/client/models/v1beta1_param_kind.py +++ b/kubernetes/client/models/v1beta1_param_kind.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ParamKind(BaseModel): diff --git a/kubernetes/client/models/v1beta1_param_ref.py b/kubernetes/client/models/v1beta1_param_ref.py index 1de44cb250..d2139352a9 100644 --- a/kubernetes/client/models/v1beta1_param_ref.py +++ b/kubernetes/client/models/v1beta1_param_ref.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ParamRef(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_certificate_request.py b/kubernetes/client/models/v1beta1_pod_certificate_request.py index 649a59cebb..e0035733e3 100644 --- a/kubernetes/client/models/v1beta1_pod_certificate_request.py +++ b/kubernetes/client/models/v1beta1_pod_certificate_request.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_certificate_request_list.py b/kubernetes/client/models/v1beta1_pod_certificate_request_list.py index b171843c74..e837ebbe50 100644 --- a/kubernetes/client/models/v1beta1_pod_certificate_request_list.py +++ b/kubernetes/client/models/v1beta1_pod_certificate_request_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_certificate_request_spec.py b/kubernetes/client/models/v1beta1_pod_certificate_request_spec.py index 369ba16099..60eedf7916 100644 --- a/kubernetes/client/models/v1beta1_pod_certificate_request_spec.py +++ b/kubernetes/client/models/v1beta1_pod_certificate_request_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_certificate_request_status.py b/kubernetes/client/models/v1beta1_pod_certificate_request_status.py index 8223782478..d8f37342bf 100644 --- a/kubernetes/client/models/v1beta1_pod_certificate_request_status.py +++ b/kubernetes/client/models/v1beta1_pod_certificate_request_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodCertificateRequestStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group.py b/kubernetes/client/models/v1beta1_pod_group.py index bc6bea4e5b..7316854633 100644 --- a/kubernetes/client/models/v1beta1_pod_group.py +++ b/kubernetes/client/models/v1beta1_pod_group.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroup(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_list.py b/kubernetes/client/models/v1beta1_pod_group_list.py index acd8b989d8..aef30461a4 100644 --- a/kubernetes/client/models/v1beta1_pod_group_list.py +++ b/kubernetes/client/models/v1beta1_pod_group_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_resource_claim.py b/kubernetes/client/models/v1beta1_pod_group_resource_claim.py index 81ad4597e5..b668e79b64 100644 --- a/kubernetes/client/models/v1beta1_pod_group_resource_claim.py +++ b/kubernetes/client/models/v1beta1_pod_group_resource_claim.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_resource_claim_status.py b/kubernetes/client/models/v1beta1_pod_group_resource_claim_status.py index 42ef3bc9be..5b1da2817b 100644 --- a/kubernetes/client/models/v1beta1_pod_group_resource_claim_status.py +++ b/kubernetes/client/models/v1beta1_pod_group_resource_claim_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_scheduling_constraints.py b/kubernetes/client/models/v1beta1_pod_group_scheduling_constraints.py index 0f27febd9e..dc144efb74 100644 --- a/kubernetes/client/models/v1beta1_pod_group_scheduling_constraints.py +++ b/kubernetes/client/models/v1beta1_pod_group_scheduling_constraints.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSchedulingConstraints(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_scheduling_policy.py b/kubernetes/client/models/v1beta1_pod_group_scheduling_policy.py index 38ef307fb4..ce1811ae43 100644 --- a/kubernetes/client/models/v1beta1_pod_group_scheduling_policy.py +++ b/kubernetes/client/models/v1beta1_pod_group_scheduling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSchedulingPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_spec.py b/kubernetes/client/models/v1beta1_pod_group_spec.py index b5ad83c253..bea70e84a3 100644 --- a/kubernetes/client/models/v1beta1_pod_group_spec.py +++ b/kubernetes/client/models/v1beta1_pod_group_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_status.py b/kubernetes/client/models/v1beta1_pod_group_status.py index 92eee34ffe..15c2bc8989 100644 --- a/kubernetes/client/models/v1beta1_pod_group_status.py +++ b/kubernetes/client/models/v1beta1_pod_group_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_pod_group_template.py b/kubernetes/client/models/v1beta1_pod_group_template.py index 9cc742ebd7..2953e044d2 100644 --- a/kubernetes/client/models/v1beta1_pod_group_template.py +++ b/kubernetes/client/models/v1beta1_pod_group_template.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1PodGroupTemplate(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim.py b/kubernetes/client/models/v1beta1_resource_claim.py index ea3c0887f9..1800f830c2 100644 --- a/kubernetes/client/models/v1beta1_resource_claim.py +++ b/kubernetes/client/models/v1beta1_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_consumer_reference.py b/kubernetes/client/models/v1beta1_resource_claim_consumer_reference.py index 032257051d..f2c8086c7b 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_consumer_reference.py +++ b/kubernetes/client/models/v1beta1_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_list.py b/kubernetes/client/models/v1beta1_resource_claim_list.py index 84d72ece3c..bf028ac396 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_list.py +++ b/kubernetes/client/models/v1beta1_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_spec.py b/kubernetes/client/models/v1beta1_resource_claim_spec.py index e37819c026..168f7bf827 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_spec.py +++ b/kubernetes/client/models/v1beta1_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_status.py b/kubernetes/client/models/v1beta1_resource_claim_status.py index 370bc177e3..e68cee6f51 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_status.py +++ b/kubernetes/client/models/v1beta1_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_template.py b/kubernetes/client/models/v1beta1_resource_claim_template.py index e61ac5029a..cffb84c04a 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_template.py +++ b/kubernetes/client/models/v1beta1_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_template_list.py b/kubernetes/client/models/v1beta1_resource_claim_template_list.py index 3a86a1ac11..04eb206a8d 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_template_list.py +++ b/kubernetes/client/models/v1beta1_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_claim_template_spec.py b/kubernetes/client/models/v1beta1_resource_claim_template_spec.py index b666308030..98635ad563 100644 --- a/kubernetes/client/models/v1beta1_resource_claim_template_spec.py +++ b/kubernetes/client/models/v1beta1_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_pool.py b/kubernetes/client/models/v1beta1_resource_pool.py index b0bb16ef38..948024f0ad 100644 --- a/kubernetes/client/models/v1beta1_resource_pool.py +++ b/kubernetes/client/models/v1beta1_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourcePool(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_slice.py b/kubernetes/client/models/v1beta1_resource_slice.py index 72bedf0385..1bd45f02bb 100644 --- a/kubernetes/client/models/v1beta1_resource_slice.py +++ b/kubernetes/client/models/v1beta1_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSlice(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_slice_list.py b/kubernetes/client/models/v1beta1_resource_slice_list.py index 809ac9475f..4528d539e8 100644 --- a/kubernetes/client/models/v1beta1_resource_slice_list.py +++ b/kubernetes/client/models/v1beta1_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSliceList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_resource_slice_spec.py b/kubernetes/client/models/v1beta1_resource_slice_spec.py index e4b4335a28..035bec3cf1 100644 --- a/kubernetes/client/models/v1beta1_resource_slice_spec.py +++ b/kubernetes/client/models/v1beta1_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1ResourceSliceSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_storage_version_migration.py b/kubernetes/client/models/v1beta1_storage_version_migration.py index 31c9fd2acb..a810e31f10 100644 --- a/kubernetes/client/models/v1beta1_storage_version_migration.py +++ b/kubernetes/client/models/v1beta1_storage_version_migration.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigration(BaseModel): diff --git a/kubernetes/client/models/v1beta1_storage_version_migration_list.py b/kubernetes/client/models/v1beta1_storage_version_migration_list.py index a89e1cd26a..94b8006b40 100644 --- a/kubernetes/client/models/v1beta1_storage_version_migration_list.py +++ b/kubernetes/client/models/v1beta1_storage_version_migration_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_storage_version_migration_spec.py b/kubernetes/client/models/v1beta1_storage_version_migration_spec.py index 959ad08eef..f90cb3254f 100644 --- a/kubernetes/client/models/v1beta1_storage_version_migration_spec.py +++ b/kubernetes/client/models/v1beta1_storage_version_migration_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta1_storage_version_migration_status.py b/kubernetes/client/models/v1beta1_storage_version_migration_status.py index 335e7fad4b..7f028b3312 100644 --- a/kubernetes/client/models/v1beta1_storage_version_migration_status.py +++ b/kubernetes/client/models/v1beta1_storage_version_migration_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1StorageVersionMigrationStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta1_topology_constraint.py b/kubernetes/client/models/v1beta1_topology_constraint.py index 485d583df7..562da8e489 100644 --- a/kubernetes/client/models/v1beta1_topology_constraint.py +++ b/kubernetes/client/models/v1beta1_topology_constraint.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1TopologyConstraint(BaseModel): diff --git a/kubernetes/client/models/v1beta1_typed_local_object_reference.py b/kubernetes/client/models/v1beta1_typed_local_object_reference.py index 3dbc8a3c30..b17d9a14fe 100644 --- a/kubernetes/client/models/v1beta1_typed_local_object_reference.py +++ b/kubernetes/client/models/v1beta1_typed_local_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1TypedLocalObjectReference(BaseModel): diff --git a/kubernetes/client/models/v1beta1_variable.py b/kubernetes/client/models/v1beta1_variable.py index 8032748b70..f24f7b6002 100644 --- a/kubernetes/client/models/v1beta1_variable.py +++ b/kubernetes/client/models/v1beta1_variable.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Variable(BaseModel): diff --git a/kubernetes/client/models/v1beta1_workload.py b/kubernetes/client/models/v1beta1_workload.py index c656dccbe3..8226c43854 100644 --- a/kubernetes/client/models/v1beta1_workload.py +++ b/kubernetes/client/models/v1beta1_workload.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1Workload(BaseModel): diff --git a/kubernetes/client/models/v1beta1_workload_list.py b/kubernetes/client/models/v1beta1_workload_list.py index 4492a1b57a..45fcf55371 100644 --- a/kubernetes/client/models/v1beta1_workload_list.py +++ b/kubernetes/client/models/v1beta1_workload_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadList(BaseModel): diff --git a/kubernetes/client/models/v1beta1_workload_reference.py b/kubernetes/client/models/v1beta1_workload_reference.py index 0533003e8b..68c6c19565 100644 --- a/kubernetes/client/models/v1beta1_workload_reference.py +++ b/kubernetes/client/models/v1beta1_workload_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadReference(BaseModel): diff --git a/kubernetes/client/models/v1beta1_workload_spec.py b/kubernetes/client/models/v1beta1_workload_spec.py index 98ec8eb1ca..82263b7441 100644 --- a/kubernetes/client/models/v1beta1_workload_spec.py +++ b/kubernetes/client/models/v1beta1_workload_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta1WorkloadSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta2_allocated_device_status.py b/kubernetes/client/models/v1beta2_allocated_device_status.py index 4f429335de..7e5b101e21 100644 --- a/kubernetes/client/models/v1beta2_allocated_device_status.py +++ b/kubernetes/client/models/v1beta2_allocated_device_status.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2AllocatedDeviceStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta2_allocation_result.py b/kubernetes/client/models/v1beta2_allocation_result.py index ce4ecd517d..eedbfc96ce 100644 --- a/kubernetes/client/models/v1beta2_allocation_result.py +++ b/kubernetes/client/models/v1beta2_allocation_result.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2AllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta2_capacity_request_policy.py b/kubernetes/client/models/v1beta2_capacity_request_policy.py index fdc3bfb480..bda5ad913e 100644 --- a/kubernetes/client/models/v1beta2_capacity_request_policy.py +++ b/kubernetes/client/models/v1beta2_capacity_request_policy.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequestPolicy(BaseModel): diff --git a/kubernetes/client/models/v1beta2_capacity_request_policy_range.py b/kubernetes/client/models/v1beta2_capacity_request_policy_range.py index cd0991acb2..fb10ac2d0b 100644 --- a/kubernetes/client/models/v1beta2_capacity_request_policy_range.py +++ b/kubernetes/client/models/v1beta2_capacity_request_policy_range.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequestPolicyRange(BaseModel): diff --git a/kubernetes/client/models/v1beta2_capacity_requirements.py b/kubernetes/client/models/v1beta2_capacity_requirements.py index f022787f19..082a71b6e1 100644 --- a/kubernetes/client/models/v1beta2_capacity_requirements.py +++ b/kubernetes/client/models/v1beta2_capacity_requirements.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CapacityRequirements(BaseModel): diff --git a/kubernetes/client/models/v1beta2_cel_device_selector.py b/kubernetes/client/models/v1beta2_cel_device_selector.py index 68c3e4b754..e03879e430 100644 --- a/kubernetes/client/models/v1beta2_cel_device_selector.py +++ b/kubernetes/client/models/v1beta2_cel_device_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CELDeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1beta2_counter.py b/kubernetes/client/models/v1beta2_counter.py index acb85de86f..d0dc794363 100644 --- a/kubernetes/client/models/v1beta2_counter.py +++ b/kubernetes/client/models/v1beta2_counter.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2Counter(BaseModel): diff --git a/kubernetes/client/models/v1beta2_counter_set.py b/kubernetes/client/models/v1beta2_counter_set.py index 1a792001e2..e40e4d383b 100644 --- a/kubernetes/client/models/v1beta2_counter_set.py +++ b/kubernetes/client/models/v1beta2_counter_set.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2CounterSet(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device.py b/kubernetes/client/models/v1beta2_device.py index 44a7ee83e1..dc051b96c8 100644 --- a/kubernetes/client/models/v1beta2_device.py +++ b/kubernetes/client/models/v1beta2_device.py @@ -31,72 +31,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2Device(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_allocation_configuration.py b/kubernetes/client/models/v1beta2_device_allocation_configuration.py index f928736ed1..da79bbfa8c 100644 --- a/kubernetes/client/models/v1beta2_device_allocation_configuration.py +++ b/kubernetes/client/models/v1beta2_device_allocation_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAllocationConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_allocation_result.py b/kubernetes/client/models/v1beta2_device_allocation_result.py index 2c0b1ecd14..5a52ace8cc 100644 --- a/kubernetes/client/models/v1beta2_device_allocation_result.py +++ b/kubernetes/client/models/v1beta2_device_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_attribute.py b/kubernetes/client/models/v1beta2_device_attribute.py index 63731b1e16..1756515b9d 100644 --- a/kubernetes/client/models/v1beta2_device_attribute.py +++ b/kubernetes/client/models/v1beta2_device_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceAttribute(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_capacity.py b/kubernetes/client/models/v1beta2_device_capacity.py index 33a6be96b2..36cf6bda77 100644 --- a/kubernetes/client/models/v1beta2_device_capacity.py +++ b/kubernetes/client/models/v1beta2_device_capacity.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceCapacity(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_claim.py b/kubernetes/client/models/v1beta2_device_claim.py index 4e403452d9..22938cbdcd 100644 --- a/kubernetes/client/models/v1beta2_device_claim.py +++ b/kubernetes/client/models/v1beta2_device_claim.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClaim(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_claim_configuration.py b/kubernetes/client/models/v1beta2_device_claim_configuration.py index 6d8baf6f90..0a93abaa9c 100644 --- a/kubernetes/client/models/v1beta2_device_claim_configuration.py +++ b/kubernetes/client/models/v1beta2_device_claim_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClaimConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_class.py b/kubernetes/client/models/v1beta2_device_class.py index 89625c4507..8b90ce7c94 100644 --- a/kubernetes/client/models/v1beta2_device_class.py +++ b/kubernetes/client/models/v1beta2_device_class.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClass(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_class_configuration.py b/kubernetes/client/models/v1beta2_device_class_configuration.py index dbfed64bee..d5220e5c72 100644 --- a/kubernetes/client/models/v1beta2_device_class_configuration.py +++ b/kubernetes/client/models/v1beta2_device_class_configuration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_class_list.py b/kubernetes/client/models/v1beta2_device_class_list.py index 25a49ba51a..57f1ae66bc 100644 --- a/kubernetes/client/models/v1beta2_device_class_list.py +++ b/kubernetes/client/models/v1beta2_device_class_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassList(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_class_spec.py b/kubernetes/client/models/v1beta2_device_class_spec.py index a7ac6ca2a6..425a988773 100644 --- a/kubernetes/client/models/v1beta2_device_class_spec.py +++ b/kubernetes/client/models/v1beta2_device_class_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceClassSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_constraint.py b/kubernetes/client/models/v1beta2_device_constraint.py index 65d1b3dd67..9ca2903827 100644 --- a/kubernetes/client/models/v1beta2_device_constraint.py +++ b/kubernetes/client/models/v1beta2_device_constraint.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceConstraint(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_counter_consumption.py b/kubernetes/client/models/v1beta2_device_counter_consumption.py index 19d7f240af..2e4414f214 100644 --- a/kubernetes/client/models/v1beta2_device_counter_consumption.py +++ b/kubernetes/client/models/v1beta2_device_counter_consumption.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceCounterConsumption(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_derived_attribute.py b/kubernetes/client/models/v1beta2_device_derived_attribute.py index 84ffb3c5fd..f40b6edc54 100644 --- a/kubernetes/client/models/v1beta2_device_derived_attribute.py +++ b/kubernetes/client/models/v1beta2_device_derived_attribute.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceDerivedAttribute(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_request.py b/kubernetes/client/models/v1beta2_device_request.py index 4d867113e8..eeb968b655 100644 --- a/kubernetes/client/models/v1beta2_device_request.py +++ b/kubernetes/client/models/v1beta2_device_request.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_request_allocation_result.py b/kubernetes/client/models/v1beta2_device_request_allocation_result.py index b56fd0e8d0..688cca8c2c 100644 --- a/kubernetes/client/models/v1beta2_device_request_allocation_result.py +++ b/kubernetes/client/models/v1beta2_device_request_allocation_result.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceRequestAllocationResult(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_selector.py b/kubernetes/client/models/v1beta2_device_selector.py index 9b3eea2b01..4e03844508 100644 --- a/kubernetes/client/models/v1beta2_device_selector.py +++ b/kubernetes/client/models/v1beta2_device_selector.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceSelector(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_sub_request.py b/kubernetes/client/models/v1beta2_device_sub_request.py index 8733dc15c0..85f16954ee 100644 --- a/kubernetes/client/models/v1beta2_device_sub_request.py +++ b/kubernetes/client/models/v1beta2_device_sub_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceSubRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint.py b/kubernetes/client/models/v1beta2_device_taint.py index dd5e80ec63..549538c12c 100644 --- a/kubernetes/client/models/v1beta2_device_taint.py +++ b/kubernetes/client/models/v1beta2_device_taint.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaint(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint_rule.py b/kubernetes/client/models/v1beta2_device_taint_rule.py index d90cc25600..d791460526 100644 --- a/kubernetes/client/models/v1beta2_device_taint_rule.py +++ b/kubernetes/client/models/v1beta2_device_taint_rule.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRule(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint_rule_list.py b/kubernetes/client/models/v1beta2_device_taint_rule_list.py index 74b543fc64..4bb80e8579 100644 --- a/kubernetes/client/models/v1beta2_device_taint_rule_list.py +++ b/kubernetes/client/models/v1beta2_device_taint_rule_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleList(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint_rule_spec.py b/kubernetes/client/models/v1beta2_device_taint_rule_spec.py index c06ba16cfd..86ad30ab1c 100644 --- a/kubernetes/client/models/v1beta2_device_taint_rule_spec.py +++ b/kubernetes/client/models/v1beta2_device_taint_rule_spec.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint_rule_status.py b/kubernetes/client/models/v1beta2_device_taint_rule_status.py index 6668002a44..e7b7c6a65e 100644 --- a/kubernetes/client/models/v1beta2_device_taint_rule_status.py +++ b/kubernetes/client/models/v1beta2_device_taint_rule_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintRuleStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_taint_selector.py b/kubernetes/client/models/v1beta2_device_taint_selector.py index 15b5dbb0b7..6940243991 100644 --- a/kubernetes/client/models/v1beta2_device_taint_selector.py +++ b/kubernetes/client/models/v1beta2_device_taint_selector.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceTaintSelector(BaseModel): diff --git a/kubernetes/client/models/v1beta2_device_toleration.py b/kubernetes/client/models/v1beta2_device_toleration.py index 65310dac84..688f2329ce 100644 --- a/kubernetes/client/models/v1beta2_device_toleration.py +++ b/kubernetes/client/models/v1beta2_device_toleration.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2DeviceToleration(BaseModel): diff --git a/kubernetes/client/models/v1beta2_exact_device_request.py b/kubernetes/client/models/v1beta2_exact_device_request.py index 2da1c84878..35c174aaf5 100644 --- a/kubernetes/client/models/v1beta2_exact_device_request.py +++ b/kubernetes/client/models/v1beta2_exact_device_request.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ExactDeviceRequest(BaseModel): diff --git a/kubernetes/client/models/v1beta2_network_device_data.py b/kubernetes/client/models/v1beta2_network_device_data.py index d537e52a2a..0fcc281c7d 100644 --- a/kubernetes/client/models/v1beta2_network_device_data.py +++ b/kubernetes/client/models/v1beta2_network_device_data.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NetworkDeviceData(BaseModel): diff --git a/kubernetes/client/models/v1beta2_node_allocatable_mapping.py b/kubernetes/client/models/v1beta2_node_allocatable_mapping.py index bfccf5c3ba..77a78c09e8 100644 --- a/kubernetes/client/models/v1beta2_node_allocatable_mapping.py +++ b/kubernetes/client/models/v1beta2_node_allocatable_mapping.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableMapping(BaseModel): diff --git a/kubernetes/client/models/v1beta2_node_allocatable_overhead.py b/kubernetes/client/models/v1beta2_node_allocatable_overhead.py index 7d24dc807b..a792afd922 100644 --- a/kubernetes/client/models/v1beta2_node_allocatable_overhead.py +++ b/kubernetes/client/models/v1beta2_node_allocatable_overhead.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableOverhead(BaseModel): diff --git a/kubernetes/client/models/v1beta2_node_allocatable_resource.py b/kubernetes/client/models/v1beta2_node_allocatable_resource.py index d7a6c158ae..d650e2e42a 100644 --- a/kubernetes/client/models/v1beta2_node_allocatable_resource.py +++ b/kubernetes/client/models/v1beta2_node_allocatable_resource.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2NodeAllocatableResource(BaseModel): diff --git a/kubernetes/client/models/v1beta2_opaque_device_configuration.py b/kubernetes/client/models/v1beta2_opaque_device_configuration.py index a13fa32102..f888283222 100644 --- a/kubernetes/client/models/v1beta2_opaque_device_configuration.py +++ b/kubernetes/client/models/v1beta2_opaque_device_configuration.py @@ -24,72 +24,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2OpaqueDeviceConfiguration(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim.py b/kubernetes/client/models/v1beta2_resource_claim.py index cdf09446ef..b62fd9235a 100644 --- a/kubernetes/client/models/v1beta2_resource_claim.py +++ b/kubernetes/client/models/v1beta2_resource_claim.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaim(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_consumer_reference.py b/kubernetes/client/models/v1beta2_resource_claim_consumer_reference.py index 848f7e1b4c..8f96e2dd16 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_consumer_reference.py +++ b/kubernetes/client/models/v1beta2_resource_claim_consumer_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimConsumerReference(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_list.py b/kubernetes/client/models/v1beta2_resource_claim_list.py index 81312e7bc8..4c0db382b2 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_list.py +++ b/kubernetes/client/models/v1beta2_resource_claim_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimList(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_spec.py b/kubernetes/client/models/v1beta2_resource_claim_spec.py index 8ba361528e..82cd17f231 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_spec.py +++ b/kubernetes/client/models/v1beta2_resource_claim_spec.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_status.py b/kubernetes/client/models/v1beta2_resource_claim_status.py index dc496d2024..97323d6e2c 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_status.py +++ b/kubernetes/client/models/v1beta2_resource_claim_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimStatus(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_template.py b/kubernetes/client/models/v1beta2_resource_claim_template.py index 1c30d8efd2..76b148cf65 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_template.py +++ b/kubernetes/client/models/v1beta2_resource_claim_template.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplate(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_template_list.py b/kubernetes/client/models/v1beta2_resource_claim_template_list.py index c98eba3825..c983547ea1 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_template_list.py +++ b/kubernetes/client/models/v1beta2_resource_claim_template_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplateList(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_claim_template_spec.py b/kubernetes/client/models/v1beta2_resource_claim_template_spec.py index c95a8604c9..3f4bf5a35e 100644 --- a/kubernetes/client/models/v1beta2_resource_claim_template_spec.py +++ b/kubernetes/client/models/v1beta2_resource_claim_template_spec.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceClaimTemplateSpec(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_pool.py b/kubernetes/client/models/v1beta2_resource_pool.py index a26e4a6ec4..ec997a24c9 100644 --- a/kubernetes/client/models/v1beta2_resource_pool.py +++ b/kubernetes/client/models/v1beta2_resource_pool.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourcePool(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_slice.py b/kubernetes/client/models/v1beta2_resource_slice.py index 91d8d807ad..238bc48e0b 100644 --- a/kubernetes/client/models/v1beta2_resource_slice.py +++ b/kubernetes/client/models/v1beta2_resource_slice.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSlice(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_slice_list.py b/kubernetes/client/models/v1beta2_resource_slice_list.py index f4edd45a32..82ffc698bd 100644 --- a/kubernetes/client/models/v1beta2_resource_slice_list.py +++ b/kubernetes/client/models/v1beta2_resource_slice_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSliceList(BaseModel): diff --git a/kubernetes/client/models/v1beta2_resource_slice_spec.py b/kubernetes/client/models/v1beta2_resource_slice_spec.py index b829462993..cf99a9e53d 100644 --- a/kubernetes/client/models/v1beta2_resource_slice_spec.py +++ b/kubernetes/client/models/v1beta2_resource_slice_spec.py @@ -29,72 +29,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V1beta2ResourceSliceSpec(BaseModel): diff --git a/kubernetes/client/models/v2_api_group_discovery.py b/kubernetes/client/models/v2_api_group_discovery.py index 8f6378e422..cbfc5871fa 100644 --- a/kubernetes/client/models/v2_api_group_discovery.py +++ b/kubernetes/client/models/v2_api_group_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIGroupDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2_api_group_discovery_list.py b/kubernetes/client/models/v2_api_group_discovery_list.py index 1421bc29df..5e7a39a01e 100644 --- a/kubernetes/client/models/v2_api_group_discovery_list.py +++ b/kubernetes/client/models/v2_api_group_discovery_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIGroupDiscoveryList(BaseModel): diff --git a/kubernetes/client/models/v2_api_resource_discovery.py b/kubernetes/client/models/v2_api_resource_discovery.py index 993b81979d..345f3c38b4 100644 --- a/kubernetes/client/models/v2_api_resource_discovery.py +++ b/kubernetes/client/models/v2_api_resource_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIResourceDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2_api_subresource_discovery.py b/kubernetes/client/models/v2_api_subresource_discovery.py index ed5c3513cd..ee2855db59 100644 --- a/kubernetes/client/models/v2_api_subresource_discovery.py +++ b/kubernetes/client/models/v2_api_subresource_discovery.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APISubresourceDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2_api_version_discovery.py b/kubernetes/client/models/v2_api_version_discovery.py index 6d6d280a8c..3c7507154c 100644 --- a/kubernetes/client/models/v2_api_version_discovery.py +++ b/kubernetes/client/models/v2_api_version_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2APIVersionDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2_container_resource_metric_source.py b/kubernetes/client/models/v2_container_resource_metric_source.py index 8b260ad2ee..5bd29ca704 100644 --- a/kubernetes/client/models/v2_container_resource_metric_source.py +++ b/kubernetes/client/models/v2_container_resource_metric_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ContainerResourceMetricSource(BaseModel): diff --git a/kubernetes/client/models/v2_container_resource_metric_status.py b/kubernetes/client/models/v2_container_resource_metric_status.py index 72a924b79c..ef9bd02961 100644 --- a/kubernetes/client/models/v2_container_resource_metric_status.py +++ b/kubernetes/client/models/v2_container_resource_metric_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ContainerResourceMetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2_cross_version_object_reference.py b/kubernetes/client/models/v2_cross_version_object_reference.py index ba81fd1d72..dcda6f8b33 100644 --- a/kubernetes/client/models/v2_cross_version_object_reference.py +++ b/kubernetes/client/models/v2_cross_version_object_reference.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2CrossVersionObjectReference(BaseModel): diff --git a/kubernetes/client/models/v2_external_metric_source.py b/kubernetes/client/models/v2_external_metric_source.py index bc9e25f354..e2bbeb7f30 100644 --- a/kubernetes/client/models/v2_external_metric_source.py +++ b/kubernetes/client/models/v2_external_metric_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ExternalMetricSource(BaseModel): diff --git a/kubernetes/client/models/v2_external_metric_status.py b/kubernetes/client/models/v2_external_metric_status.py index e14af3a5e0..049e390595 100644 --- a/kubernetes/client/models/v2_external_metric_status.py +++ b/kubernetes/client/models/v2_external_metric_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ExternalMetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler.py index 2ce1fdf5fd..6e0ed24a1d 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscaler(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler_behavior.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler_behavior.py index 0d61fc4492..19a2ed02ab 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler_behavior.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler_behavior.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerBehavior(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler_condition.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler_condition.py index 939ebf388f..7634957d0f 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler_condition.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler_condition.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerCondition(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler_list.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler_list.py index 30d908f692..d5d853bf96 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler_list.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerList(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler_spec.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler_spec.py index 1e778a8872..00d09f0581 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler_spec.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler_spec.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerSpec(BaseModel): diff --git a/kubernetes/client/models/v2_horizontal_pod_autoscaler_status.py b/kubernetes/client/models/v2_horizontal_pod_autoscaler_status.py index 480471dc7b..c2c0983d30 100644 --- a/kubernetes/client/models/v2_horizontal_pod_autoscaler_status.py +++ b/kubernetes/client/models/v2_horizontal_pod_autoscaler_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HorizontalPodAutoscalerStatus(BaseModel): diff --git a/kubernetes/client/models/v2_hpa_scaling_policy.py b/kubernetes/client/models/v2_hpa_scaling_policy.py index 8e63e1a4a5..8fc1c3ebf3 100644 --- a/kubernetes/client/models/v2_hpa_scaling_policy.py +++ b/kubernetes/client/models/v2_hpa_scaling_policy.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HPAScalingPolicy(BaseModel): diff --git a/kubernetes/client/models/v2_hpa_scaling_rules.py b/kubernetes/client/models/v2_hpa_scaling_rules.py index 994284a333..61aee8b4c3 100644 --- a/kubernetes/client/models/v2_hpa_scaling_rules.py +++ b/kubernetes/client/models/v2_hpa_scaling_rules.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2HPAScalingRules(BaseModel): diff --git a/kubernetes/client/models/v2_metric_identifier.py b/kubernetes/client/models/v2_metric_identifier.py index b1864e6a12..7be388b0b4 100644 --- a/kubernetes/client/models/v2_metric_identifier.py +++ b/kubernetes/client/models/v2_metric_identifier.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricIdentifier(BaseModel): diff --git a/kubernetes/client/models/v2_metric_spec.py b/kubernetes/client/models/v2_metric_spec.py index b8b6abaa0d..b70bf892db 100644 --- a/kubernetes/client/models/v2_metric_spec.py +++ b/kubernetes/client/models/v2_metric_spec.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricSpec(BaseModel): diff --git a/kubernetes/client/models/v2_metric_status.py b/kubernetes/client/models/v2_metric_status.py index fe6c274ee4..a181462435 100644 --- a/kubernetes/client/models/v2_metric_status.py +++ b/kubernetes/client/models/v2_metric_status.py @@ -30,72 +30,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2_metric_target.py b/kubernetes/client/models/v2_metric_target.py index cd5c47b8d0..42902c7b47 100644 --- a/kubernetes/client/models/v2_metric_target.py +++ b/kubernetes/client/models/v2_metric_target.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricTarget(BaseModel): diff --git a/kubernetes/client/models/v2_metric_value_status.py b/kubernetes/client/models/v2_metric_value_status.py index b3fe5b4ca7..29fbbbed70 100644 --- a/kubernetes/client/models/v2_metric_value_status.py +++ b/kubernetes/client/models/v2_metric_value_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2MetricValueStatus(BaseModel): diff --git a/kubernetes/client/models/v2_object_metric_source.py b/kubernetes/client/models/v2_object_metric_source.py index 918c9b2573..f5c76e8d78 100644 --- a/kubernetes/client/models/v2_object_metric_source.py +++ b/kubernetes/client/models/v2_object_metric_source.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ObjectMetricSource(BaseModel): diff --git a/kubernetes/client/models/v2_object_metric_status.py b/kubernetes/client/models/v2_object_metric_status.py index 8c97625fa9..66598907ca 100644 --- a/kubernetes/client/models/v2_object_metric_status.py +++ b/kubernetes/client/models/v2_object_metric_status.py @@ -28,72 +28,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ObjectMetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2_pods_metric_source.py b/kubernetes/client/models/v2_pods_metric_source.py index 0d2f87f9cf..aa0d8f2fde 100644 --- a/kubernetes/client/models/v2_pods_metric_source.py +++ b/kubernetes/client/models/v2_pods_metric_source.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2PodsMetricSource(BaseModel): diff --git a/kubernetes/client/models/v2_pods_metric_status.py b/kubernetes/client/models/v2_pods_metric_status.py index d450575ae2..a4583e3f65 100644 --- a/kubernetes/client/models/v2_pods_metric_status.py +++ b/kubernetes/client/models/v2_pods_metric_status.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2PodsMetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2_resource_metric_source.py b/kubernetes/client/models/v2_resource_metric_source.py index 99a2453c43..aefae59fe5 100644 --- a/kubernetes/client/models/v2_resource_metric_source.py +++ b/kubernetes/client/models/v2_resource_metric_source.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ResourceMetricSource(BaseModel): diff --git a/kubernetes/client/models/v2_resource_metric_status.py b/kubernetes/client/models/v2_resource_metric_status.py index 90a965790f..51814bed9b 100644 --- a/kubernetes/client/models/v2_resource_metric_status.py +++ b/kubernetes/client/models/v2_resource_metric_status.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2ResourceMetricStatus(BaseModel): diff --git a/kubernetes/client/models/v2beta1_api_group_discovery.py b/kubernetes/client/models/v2beta1_api_group_discovery.py index 0d7f867768..ceb144b31e 100644 --- a/kubernetes/client/models/v2beta1_api_group_discovery.py +++ b/kubernetes/client/models/v2beta1_api_group_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIGroupDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2beta1_api_group_discovery_list.py b/kubernetes/client/models/v2beta1_api_group_discovery_list.py index 9d2acc6edf..5bcd10a985 100644 --- a/kubernetes/client/models/v2beta1_api_group_discovery_list.py +++ b/kubernetes/client/models/v2beta1_api_group_discovery_list.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIGroupDiscoveryList(BaseModel): diff --git a/kubernetes/client/models/v2beta1_api_resource_discovery.py b/kubernetes/client/models/v2beta1_api_resource_discovery.py index 5b67763d9f..94e741d5c2 100644 --- a/kubernetes/client/models/v2beta1_api_resource_discovery.py +++ b/kubernetes/client/models/v2beta1_api_resource_discovery.py @@ -27,72 +27,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIResourceDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2beta1_api_subresource_discovery.py b/kubernetes/client/models/v2beta1_api_subresource_discovery.py index 255efdc164..b3abdc35f1 100644 --- a/kubernetes/client/models/v2beta1_api_subresource_discovery.py +++ b/kubernetes/client/models/v2beta1_api_subresource_discovery.py @@ -26,72 +26,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APISubresourceDiscovery(BaseModel): diff --git a/kubernetes/client/models/v2beta1_api_version_discovery.py b/kubernetes/client/models/v2beta1_api_version_discovery.py index 91f4c86e21..1786b69fa2 100644 --- a/kubernetes/client/models/v2beta1_api_version_discovery.py +++ b/kubernetes/client/models/v2beta1_api_version_discovery.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class V2beta1APIVersionDiscovery(BaseModel): diff --git a/kubernetes/client/models/version_info.py b/kubernetes/client/models/version_info.py index d31a9841ba..994aa2f544 100644 --- a/kubernetes/client/models/version_info.py +++ b/kubernetes/client/models/version_info.py @@ -25,72 +25,12 @@ from pydantic_core import to_jsonable_python -_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict" - - -def _get_openapi_to_dict(value: Any) -> Any: - # Reciprocal function references preserve inherited generated methods - # without reserving model member names. Checking both directions also - # rejects overrides whose decorators copy function attributes. - to_dict = getattr(value, "to_dict", None) - type_to_dict = getattr(type(value), "to_dict", None) - if ( - not callable(to_dict) - or getattr(to_dict, "__func__", None) is not type_to_dict - ): - return None - - openapi_to_dict = getattr( - type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None - ) - if ( - not callable(openapi_to_dict) - or getattr( - openapi_to_dict, - _OPENAPI_GENERATOR_TO_DICT, - None, - ) is not type_to_dict - ): - return None - return openapi_to_dict - - -def _to_legacy_item(value: Any, serialize: bool) -> Any: - to_dict = getattr(value, "to_dict", None) - if _get_openapi_to_dict(value) is not None and callable(to_dict): - return to_dict(serialize=serialize) - if callable(to_dict): - return to_dict() - return value - - -def _to_legacy_value(value: Any, serialize: bool) -> Any: - # python-legacy converted only immediate list elements or dictionary values: - # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231 - if isinstance(value, list): - return [_to_legacy_item(item, serialize) for item in value] - if isinstance(value, dict): - return { - key: _to_legacy_item(item, serialize) - for key, item in value.items() - } - return _to_legacy_item(value, serialize) - - -def _to_openapi_value(value: Any) -> Any: - if isinstance(value, list): - return [_to_openapi_value(item) for item in value] - if isinstance(value, dict): - return {key: _to_openapi_value(item) for key, item in value.items()} - - to_openapi_dict = _get_openapi_to_dict(value) - if to_openapi_dict is not None: - return to_openapi_dict(value) - - to_dict = getattr(value, "to_dict", None) - if callable(to_dict): - return to_dict() - return value +from kubernetes.client._legacy_model_helpers import ( + _OPENAPI_GENERATOR_TO_DICT, + _get_openapi_to_dict, + _to_legacy_value, + _to_openapi_value, +) class VersionInfo(BaseModel): diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py index 1a1015d75e..27f87034d1 100644 --- a/kubernetes/client/rest.py +++ b/kubernetes/client/rest.py @@ -230,7 +230,7 @@ def request( ) post_params = post_params or {} - headers = headers or {} + headers = urllib3.HTTPHeaderDict(headers or {}) timeout = None if _request_timeout: diff --git a/kubernetes/test/test_legacy_model_helpers.py b/kubernetes/test/test_legacy_model_helpers.py new file mode 100644 index 0000000000..d2edced323 --- /dev/null +++ b/kubernetes/test/test_legacy_model_helpers.py @@ -0,0 +1,96 @@ +# Copyright 2026 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json + +import pytest + +from kubernetes import client +from kubernetes.aio import client as aio_client + + +@pytest.fixture(params=[client, aio_client], ids=["sync", "asyncio"]) +def models(request): + return request.param + + +def test_nested_models_keep_legacy_and_wire_field_names(models): + pod = models.V1Pod( + api_version="v1", + metadata=models.V1ObjectMeta(name="example"), + spec=models.V1PodSpec( + containers=[models.V1Container(name="app", image="example:v1")], + service_account_name="worker", + ), + ) + + legacy = pod.to_dict() + assert legacy["api_version"] == "v1" + assert legacy["status"] is None + assert legacy["spec"]["service_account_name"] == "worker" + assert legacy["spec"]["containers"][0]["image"] == "example:v1" + + wire = pod.to_dict(serialize=True) + assert wire["apiVersion"] == "v1" + assert wire["status"] is None + assert wire["spec"]["serviceAccountName"] == "worker" + + expected = { + "apiVersion": "v1", + "metadata": {"name": "example"}, + "spec": { + "containers": [{"name": "app", "image": "example:v1"}], + "serviceAccountName": "worker", + }, + } + assert json.loads(pod.to_json()) == expected + api_client = object.__new__(models.ApiClient) + assert api_client.sanitize_for_serialization(pod) == expected + + +def test_inherited_model_keeps_generated_serialization(models): + class CustomPod(models.V1Pod): + pass + + pod = CustomPod(api_version="v1") + assert pod.to_dict()["api_version"] == "v1" + assert pod.to_dict(serialize=True)["apiVersion"] == "v1" + assert json.loads(pod.to_json()) == {"apiVersion": "v1"} + + +def test_nested_to_dict_override_accepts_no_serialize_argument(models): + class CustomMetadata(models.V1ObjectMeta): + def to_dict(self): + return {"customName": self.name} + + pod = models.V1Pod(metadata=CustomMetadata(name="example")) + assert pod.to_dict()["metadata"] == {"customName": "example"} + assert pod.to_dict(serialize=True)["metadata"] == { + "customName": "example", + } + assert json.loads(pod.to_json()) == { + "metadata": {"customName": "example"}, + } + + +def test_dictionary_values_keep_legacy_conversion(models): + resource = models.V1JSONSchemaProps( + properties={"name": models.V1JSONSchemaProps(type="string")}, + ) + assert resource.to_dict()["properties"]["name"]["type"] == "string" + wire = resource.to_dict(serialize=True) + assert wire["properties"]["name"]["type"] == "string" + assert json.loads(resource.to_json()) == { + "properties": {"name": {"type": "string"}}, + } diff --git a/scripts/client_go_retry_asyncio_patch.diff b/scripts/client_go_retry_asyncio_patch.diff index 00becd4e26..eda79c481f 100644 --- a/scripts/client_go_retry_asyncio_patch.diff +++ b/scripts/client_go_retry_asyncio_patch.diff @@ -27,9 +27,10 @@ diff --git a/kubernetes/aio/client/configuration.py b/kubernetes/aio/client/conf diff --git a/kubernetes/aio/client/rest.py b/kubernetes/aio/client/rest.py --- a/kubernetes/aio/client/rest.py +++ b/kubernetes/aio/client/rest.py -@@ -21,6 +21,11 @@ +@@ -21,7 +21,12 @@ import aiohttp import aiohttp_retry + from multidict import CIMultiDict +from kubernetes.aio.utils.retry import ( + is_retry_after_response, diff --git a/scripts/constants.py b/scripts/constants.py index 5a8618ad77..ee9b94ae95 100644 --- a/scripts/constants.py +++ b/scripts/constants.py @@ -17,6 +17,9 @@ # Kubernetes branch to get the OpenAPI spec from. KUBERNETES_BRANCH = "release-1.37" +# Includes OpenAPITools/openapi-generator#24730 (shared legacy model helpers). +OPENAPI_GENERATOR_COMMIT = "3cf4b374881ed853d522d67b326428e09defcf29" + # client version for packaging and releasing. CLIENT_VERSION = "37.0.0+snapshot" diff --git a/scripts/update-client-asyncio.sh b/scripts/update-client-asyncio.sh index 2de63e9c8e..6958218a61 100755 --- a/scripts/update-client-asyncio.sh +++ b/scripts/update-client-asyncio.sh @@ -34,6 +34,8 @@ popd > /dev/null source ${SCRIPT_ROOT}/util/common.sh util::common::check_sed +export OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-$(python "${SCRIPT_ROOT}/constants.py" OPENAPI_GENERATOR_COMMIT)}" + pushd "${CLIENT_ROOT}" > /dev/null CLIENT_ROOT=`pwd` popd > /dev/null diff --git a/scripts/update-client.sh b/scripts/update-client.sh index 102db9a1b7..eaa7b59234 100755 --- a/scripts/update-client.sh +++ b/scripts/update-client.sh @@ -35,6 +35,8 @@ popd > /dev/null source ${SCRIPT_ROOT}/util/common.sh util::common::check_sed +export OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-$(python "${SCRIPT_ROOT}/constants.py" OPENAPI_GENERATOR_COMMIT)}" + pushd "${CLIENT_ROOT}" > /dev/null CLIENT_ROOT=`pwd` popd > /dev/null