=begin
#Kubernetes

#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

OpenAPI spec version: v1.13.4

Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.2.3

=end

require 'date'

module Kubernetes
  # PodSpec is a description of a pod.
  class V1PodSpec
    # Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.
    attr_accessor :active_deadline_seconds

    # If specified, the pod's scheduling constraints
    attr_accessor :affinity

    # AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.
    attr_accessor :automount_service_account_token

    # List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.
    attr_accessor :containers

    # Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.
    attr_accessor :dns_config

    # Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.
    attr_accessor :dns_policy

    # EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links.
    attr_accessor :enable_service_links

    # HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.
    attr_accessor :host_aliases

    # Use the host's ipc namespace. Optional: Default to false.
    attr_accessor :host_ipc

    # Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.
    attr_accessor :host_network

    # Use the host's pid namespace. Optional: Default to false.
    attr_accessor :host_pid

    # Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.
    attr_accessor :hostname

    # ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
    attr_accessor :image_pull_secrets

    # List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, or Liveness probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
    attr_accessor :init_containers

    # NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.
    attr_accessor :node_name

    # NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
    attr_accessor :node_selector

    # The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.
    attr_accessor :priority

    # If specified, indicates the pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.
    attr_accessor :priority_class_name

    # If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to \"True\" More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md
    attr_accessor :readiness_gates

    # Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
    attr_accessor :restart_policy

    # RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod.  If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future.
    attr_accessor :runtime_class_name

    # If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.
    attr_accessor :scheduler_name

    # SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty.  See type description for default values of each field.
    attr_accessor :security_context

    # DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.
    attr_accessor :service_account

    # ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
    attr_accessor :service_account_name

    # Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set. Optional: Default to false. This field is beta-level and may be disabled with the PodShareProcessNamespace feature.
    attr_accessor :share_process_namespace

    # If specified, the fully qualified Pod hostname will be \"<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>\". If not specified, the pod will not have a domainname at all.
    attr_accessor :subdomain

    # Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.
    attr_accessor :termination_grace_period_seconds

    # If specified, the pod's tolerations.
    attr_accessor :tolerations

    # List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes
    attr_accessor :volumes


    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'active_deadline_seconds' => :'activeDeadlineSeconds',
        :'affinity' => :'affinity',
        :'automount_service_account_token' => :'automountServiceAccountToken',
        :'containers' => :'containers',
        :'dns_config' => :'dnsConfig',
        :'dns_policy' => :'dnsPolicy',
        :'enable_service_links' => :'enableServiceLinks',
        :'host_aliases' => :'hostAliases',
        :'host_ipc' => :'hostIPC',
        :'host_network' => :'hostNetwork',
        :'host_pid' => :'hostPID',
        :'hostname' => :'hostname',
        :'image_pull_secrets' => :'imagePullSecrets',
        :'init_containers' => :'initContainers',
        :'node_name' => :'nodeName',
        :'node_selector' => :'nodeSelector',
        :'priority' => :'priority',
        :'priority_class_name' => :'priorityClassName',
        :'readiness_gates' => :'readinessGates',
        :'restart_policy' => :'restartPolicy',
        :'runtime_class_name' => :'runtimeClassName',
        :'scheduler_name' => :'schedulerName',
        :'security_context' => :'securityContext',
        :'service_account' => :'serviceAccount',
        :'service_account_name' => :'serviceAccountName',
        :'share_process_namespace' => :'shareProcessNamespace',
        :'subdomain' => :'subdomain',
        :'termination_grace_period_seconds' => :'terminationGracePeriodSeconds',
        :'tolerations' => :'tolerations',
        :'volumes' => :'volumes'
      }
    end

    # Attribute type mapping.
    def self.swagger_types
      {
        :'active_deadline_seconds' => :'Integer',
        :'affinity' => :'V1Affinity',
        :'automount_service_account_token' => :'BOOLEAN',
        :'containers' => :'Array<V1Container>',
        :'dns_config' => :'V1PodDNSConfig',
        :'dns_policy' => :'String',
        :'enable_service_links' => :'BOOLEAN',
        :'host_aliases' => :'Array<V1HostAlias>',
        :'host_ipc' => :'BOOLEAN',
        :'host_network' => :'BOOLEAN',
        :'host_pid' => :'BOOLEAN',
        :'hostname' => :'String',
        :'image_pull_secrets' => :'Array<V1LocalObjectReference>',
        :'init_containers' => :'Array<V1Container>',
        :'node_name' => :'String',
        :'node_selector' => :'Hash<String, String>',
        :'priority' => :'Integer',
        :'priority_class_name' => :'String',
        :'readiness_gates' => :'Array<V1PodReadinessGate>',
        :'restart_policy' => :'String',
        :'runtime_class_name' => :'String',
        :'scheduler_name' => :'String',
        :'security_context' => :'V1PodSecurityContext',
        :'service_account' => :'String',
        :'service_account_name' => :'String',
        :'share_process_namespace' => :'BOOLEAN',
        :'subdomain' => :'String',
        :'termination_grace_period_seconds' => :'Integer',
        :'tolerations' => :'Array<V1Toleration>',
        :'volumes' => :'Array<V1Volume>'
      }
    end

    # Initializes the object
    # @param [Hash] attributes Model attributes in the form of hash
    def initialize(attributes = {})
      return unless attributes.is_a?(Hash)

      # convert string to symbol for hash key
      attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

      if attributes.has_key?(:'activeDeadlineSeconds')
        self.active_deadline_seconds = attributes[:'activeDeadlineSeconds']
      end

      if attributes.has_key?(:'affinity')
        self.affinity = attributes[:'affinity']
      end

      if attributes.has_key?(:'automountServiceAccountToken')
        self.automount_service_account_token = attributes[:'automountServiceAccountToken']
      end

      if attributes.has_key?(:'containers')
        if (value = attributes[:'containers']).is_a?(Array)
          self.containers = value
        end
      end

      if attributes.has_key?(:'dnsConfig')
        self.dns_config = attributes[:'dnsConfig']
      end

      if attributes.has_key?(:'dnsPolicy')
        self.dns_policy = attributes[:'dnsPolicy']
      end

      if attributes.has_key?(:'enableServiceLinks')
        self.enable_service_links = attributes[:'enableServiceLinks']
      end

      if attributes.has_key?(:'hostAliases')
        if (value = attributes[:'hostAliases']).is_a?(Array)
          self.host_aliases = value
        end
      end

      if attributes.has_key?(:'hostIPC')
        self.host_ipc = attributes[:'hostIPC']
      end

      if attributes.has_key?(:'hostNetwork')
        self.host_network = attributes[:'hostNetwork']
      end

      if attributes.has_key?(:'hostPID')
        self.host_pid = attributes[:'hostPID']
      end

      if attributes.has_key?(:'hostname')
        self.hostname = attributes[:'hostname']
      end

      if attributes.has_key?(:'imagePullSecrets')
        if (value = attributes[:'imagePullSecrets']).is_a?(Array)
          self.image_pull_secrets = value
        end
      end

      if attributes.has_key?(:'initContainers')
        if (value = attributes[:'initContainers']).is_a?(Array)
          self.init_containers = value
        end
      end

      if attributes.has_key?(:'nodeName')
        self.node_name = attributes[:'nodeName']
      end

      if attributes.has_key?(:'nodeSelector')
        if (value = attributes[:'nodeSelector']).is_a?(Array)
          self.node_selector = value
        end
      end

      if attributes.has_key?(:'priority')
        self.priority = attributes[:'priority']
      end

      if attributes.has_key?(:'priorityClassName')
        self.priority_class_name = attributes[:'priorityClassName']
      end

      if attributes.has_key?(:'readinessGates')
        if (value = attributes[:'readinessGates']).is_a?(Array)
          self.readiness_gates = value
        end
      end

      if attributes.has_key?(:'restartPolicy')
        self.restart_policy = attributes[:'restartPolicy']
      end

      if attributes.has_key?(:'runtimeClassName')
        self.runtime_class_name = attributes[:'runtimeClassName']
      end

      if attributes.has_key?(:'schedulerName')
        self.scheduler_name = attributes[:'schedulerName']
      end

      if attributes.has_key?(:'securityContext')
        self.security_context = attributes[:'securityContext']
      end

      if attributes.has_key?(:'serviceAccount')
        self.service_account = attributes[:'serviceAccount']
      end

      if attributes.has_key?(:'serviceAccountName')
        self.service_account_name = attributes[:'serviceAccountName']
      end

      if attributes.has_key?(:'shareProcessNamespace')
        self.share_process_namespace = attributes[:'shareProcessNamespace']
      end

      if attributes.has_key?(:'subdomain')
        self.subdomain = attributes[:'subdomain']
      end

      if attributes.has_key?(:'terminationGracePeriodSeconds')
        self.termination_grace_period_seconds = attributes[:'terminationGracePeriodSeconds']
      end

      if attributes.has_key?(:'tolerations')
        if (value = attributes[:'tolerations']).is_a?(Array)
          self.tolerations = value
        end
      end

      if attributes.has_key?(:'volumes')
        if (value = attributes[:'volumes']).is_a?(Array)
          self.volumes = value
        end
      end

    end

    # Show invalid properties with the reasons. Usually used together with valid?
    # @return Array for valid properies with the reasons
    def list_invalid_properties
      invalid_properties = Array.new
      if @containers.nil?
        invalid_properties.push("invalid value for 'containers', containers cannot be nil.")
      end

      return 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 @containers.nil?
      return true
    end

    # Checks equality by comparing each attribute.
    # @param [Object] Object to be compared
    def ==(o)
      return true if self.equal?(o)
      self.class == o.class &&
          active_deadline_seconds == o.active_deadline_seconds &&
          affinity == o.affinity &&
          automount_service_account_token == o.automount_service_account_token &&
          containers == o.containers &&
          dns_config == o.dns_config &&
          dns_policy == o.dns_policy &&
          enable_service_links == o.enable_service_links &&
          host_aliases == o.host_aliases &&
          host_ipc == o.host_ipc &&
          host_network == o.host_network &&
          host_pid == o.host_pid &&
          hostname == o.hostname &&
          image_pull_secrets == o.image_pull_secrets &&
          init_containers == o.init_containers &&
          node_name == o.node_name &&
          node_selector == o.node_selector &&
          priority == o.priority &&
          priority_class_name == o.priority_class_name &&
          readiness_gates == o.readiness_gates &&
          restart_policy == o.restart_policy &&
          runtime_class_name == o.runtime_class_name &&
          scheduler_name == o.scheduler_name &&
          security_context == o.security_context &&
          service_account == o.service_account &&
          service_account_name == o.service_account_name &&
          share_process_namespace == o.share_process_namespace &&
          subdomain == o.subdomain &&
          termination_grace_period_seconds == o.termination_grace_period_seconds &&
          tolerations == o.tolerations &&
          volumes == o.volumes
    end

    # @see the `==` method
    # @param [Object] Object to be compared
    def eql?(o)
      self == o
    end

    # Calculates hash code according to all attributes.
    # @return [Fixnum] Hash code
    def hash
      [active_deadline_seconds, affinity, automount_service_account_token, containers, dns_config, dns_policy, enable_service_links, host_aliases, host_ipc, host_network, host_pid, hostname, image_pull_secrets, init_containers, node_name, node_selector, priority, priority_class_name, readiness_gates, restart_policy, runtime_class_name, scheduler_name, security_context, service_account, service_account_name, share_process_namespace, subdomain, termination_grace_period_seconds, tolerations, volumes].hash
    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)
      self.class.swagger_types.each_pair do |key, type|
        if type =~ /\AArray<(.*)>/i
          # check to ensure the input is an array given that the the attribute
          # is documented as an array but the input is not
          if attributes[self.class.attribute_map[key]].is_a?(Array)
            self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
          end
        elsif !attributes[self.class.attribute_map[key]].nil?
          self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
        end # or else data not found in attributes(hash), not an issue as the data can be optional
      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 :DateTime
        DateTime.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<(?<inner_type>.+)>\z/
        inner_type = Regexp.last_match[:inner_type]
        value.map { |v| _deserialize(inner_type, v) }
      when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
        temp_model = Kubernetes.const_get(type).new
        temp_model.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 = self.send(attr)
        next if value.nil?
        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
