# frozen_string_literal: true # #Kubernetes # # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # # The version of the OpenAPI document: unversioned # # Generated by: https://openapi-generator.tech # OpenAPI Generator version: 6.5.0-SNAPSHOT # require 'date' require 'time' module Zilla # A single application container that you want to run within a pod. class IoK8sApiCoreV1Container # Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell attr_accessor :args # Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell attr_accessor :command # List of environment variables to set in the container. Cannot be updated. attr_accessor :env # List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated. attr_accessor :env_from # Container image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets. attr_accessor :image # Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images attr_accessor :image_pull_policy attr_accessor :lifecycle, :liveness_probe, :readiness_probe, :resources, :security_context, :startup_probe # Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated. attr_accessor :name # List of ports to expose from the container. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default \"0.0.0.0\" address inside a container will be accessible from the network. Modifying this array with strategic merge patch may corrupt the data. For more information See https://github.com/kubernetes/kubernetes/issues/108255. Cannot be updated. attr_accessor :ports # Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false. attr_accessor :stdin # Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false attr_accessor :stdin_once # Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated. attr_accessor :termination_message_path # Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated. attr_accessor :termination_message_policy # Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false. attr_accessor :tty # volumeDevices is the list of block devices to be used by the container. attr_accessor :volume_devices # Pod volumes to mount into the container's filesystem. Cannot be updated. attr_accessor :volume_mounts # Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated. attr_accessor :working_dir # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { args: :args, command: :command, env: :env, env_from: :envFrom, image: :image, image_pull_policy: :imagePullPolicy, lifecycle: :lifecycle, liveness_probe: :livenessProbe, name: :name, ports: :ports, readiness_probe: :readinessProbe, resources: :resources, security_context: :securityContext, startup_probe: :startupProbe, stdin: :stdin, stdin_once: :stdinOnce, termination_message_path: :terminationMessagePath, termination_message_policy: :terminationMessagePolicy, tty: :tty, volume_devices: :volumeDevices, volume_mounts: :volumeMounts, working_dir: :workingDir } end # Returns all the JSON keys this model knows about def self.acceptable_attributes attribute_map.values end # Attribute type mapping. def self.openapi_types { args: :'Array', command: :'Array', env: :'Array', env_from: :'Array', image: :String, image_pull_policy: :String, lifecycle: :IoK8sApiCoreV1Lifecycle, liveness_probe: :IoK8sApiCoreV1Probe, name: :String, ports: :'Array', readiness_probe: :IoK8sApiCoreV1Probe, resources: :IoK8sApiCoreV1ResourceRequirements, security_context: :IoK8sApiCoreV1SecurityContext, startup_probe: :IoK8sApiCoreV1Probe, stdin: :Boolean, stdin_once: :Boolean, termination_message_path: :String, termination_message_policy: :String, tty: :Boolean, volume_devices: :'Array', volume_mounts: :'Array', working_dir: :String } end # List of attributes with nullable: true def self.openapi_nullable Set.new([]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) unless attributes.is_a?(Hash) raise ArgumentError, 'The input argument (attributes) must be a hash in `Zilla::IoK8sApiCoreV1Container` initialize method' end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) do |(k, v), h| unless self.class.attribute_map.key?(k.to_sym) raise ArgumentError, "`#{k}` is not a valid attribute in `Zilla::IoK8sApiCoreV1Container`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v end if attributes.key?(:args) && (value = attributes[:args]).is_a?(Array) self.args = value end if attributes.key?(:command) && (value = attributes[:command]).is_a?(Array) self.command = value end if attributes.key?(:env) && (value = attributes[:env]).is_a?(Array) self.env = value end if attributes.key?(:env_from) && (value = attributes[:env_from]).is_a?(Array) self.env_from = value end self.image = attributes[:image] if attributes.key?(:image) self.image_pull_policy = attributes[:image_pull_policy] if attributes.key?(:image_pull_policy) self.lifecycle = attributes[:lifecycle] if attributes.key?(:lifecycle) self.liveness_probe = attributes[:liveness_probe] if attributes.key?(:liveness_probe) self.name = attributes[:name] if attributes.key?(:name) if attributes.key?(:ports) && (value = attributes[:ports]).is_a?(Array) self.ports = value end self.readiness_probe = attributes[:readiness_probe] if attributes.key?(:readiness_probe) self.resources = attributes[:resources] if attributes.key?(:resources) self.security_context = attributes[:security_context] if attributes.key?(:security_context) self.startup_probe = attributes[:startup_probe] if attributes.key?(:startup_probe) self.stdin = attributes[:stdin] if attributes.key?(:stdin) self.stdin_once = attributes[:stdin_once] if attributes.key?(:stdin_once) if attributes.key?(:termination_message_path) self.termination_message_path = attributes[:termination_message_path] end if attributes.key?(:termination_message_policy) self.termination_message_policy = attributes[:termination_message_policy] end self.tty = attributes[:tty] if attributes.key?(:tty) if attributes.key?(:volume_devices) && (value = attributes[:volume_devices]).is_a?(Array) self.volume_devices = value end if attributes.key?(:volume_mounts) && (value = attributes[:volume_mounts]).is_a?(Array) self.volume_mounts = value end return unless attributes.key?(:working_dir) self.working_dir = attributes[:working_dir] end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = [] invalid_properties.push('invalid value for "name", name cannot be nil.') if @name.nil? invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @name.nil? true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(other) return true if equal?(other) self.class == other.class && args == other.args && command == other.command && env == other.env && env_from == other.env_from && image == other.image && image_pull_policy == other.image_pull_policy && lifecycle == other.lifecycle && liveness_probe == other.liveness_probe && name == other.name && ports == other.ports && readiness_probe == other.readiness_probe && resources == other.resources && security_context == other.security_context && startup_probe == other.startup_probe && stdin == other.stdin && stdin_once == other.stdin_once && termination_message_path == other.termination_message_path && termination_message_policy == other.termination_message_policy && tty == other.tty && volume_devices == other.volume_devices && volume_mounts == other.volume_mounts && working_dir == other.working_dir end # @see the `==` method # @param [Object] Object to be compared def eql?(other) self == other end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [args, command, env, env_from, image, image_pull_policy, lifecycle, liveness_probe, name, ports, readiness_probe, resources, security_context, startup_probe, stdin, stdin_once, termination_message_path, termination_message_policy, tty, volume_devices, volume_mounts, working_dir].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) new.build_from_hash(attributes) end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) send("#{key}=", attributes[self.class.attribute_map[key]].map do |v| _deserialize(::Regexp.last_match(1), v) end) end elsif !attributes[self.class.attribute_map[key]].nil? send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Zilla.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end