=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
  # PersistentVolumeSpec is the specification of a persistent volume.
  class V1PersistentVolumeSpec
    # AccessModes contains all ways the volume can be mounted. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes
    attr_accessor :access_modes

    # AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore
    attr_accessor :aws_elastic_block_store

    # AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
    attr_accessor :azure_disk

    # AzureFile represents an Azure File Service mount on the host and bind mount to the pod.
    attr_accessor :azure_file

    # A description of the persistent volume's resources and capacity. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity
    attr_accessor :capacity

    # CephFS represents a Ceph FS mount on the host that shares a pod's lifetime
    attr_accessor :cephfs

    # Cinder represents a cinder volume attached and mounted on kubelets host machine More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md
    attr_accessor :cinder

    # ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim.VolumeName is the authoritative bind between PV and PVC. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#binding
    attr_accessor :claim_ref

    # CSI represents storage that handled by an external CSI driver (Beta feature).
    attr_accessor :csi

    # FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.
    attr_accessor :fc

    # FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.
    attr_accessor :flex_volume

    # Flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running
    attr_accessor :flocker

    # GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
    attr_accessor :gce_persistent_disk

    # Glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md
    attr_accessor :glusterfs

    # HostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath
    attr_accessor :host_path

    # ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin.
    attr_accessor :iscsi

    # Local represents directly-attached storage with node affinity
    attr_accessor :local

    # A list of mount options, e.g. [\"ro\", \"soft\"]. Not validated - mount will simply fail if one is invalid. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options
    attr_accessor :mount_options

    # NFS represents an NFS mount on the host. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
    attr_accessor :nfs

    # NodeAffinity defines constraints that limit what nodes this volume can be accessed from. This field influences the scheduling of pods that use this volume.
    attr_accessor :node_affinity

    # What happens to a persistent volume when released from its claim. Valid options are Retain (default for manually created PersistentVolumes), Delete (default for dynamically provisioned PersistentVolumes), and Recycle (deprecated). Recycle must be supported by the volume plugin underlying this PersistentVolume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming
    attr_accessor :persistent_volume_reclaim_policy

    # PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
    attr_accessor :photon_persistent_disk

    # PortworxVolume represents a portworx volume attached and mounted on kubelets host machine
    attr_accessor :portworx_volume

    # Quobyte represents a Quobyte mount on the host that shares a pod's lifetime
    attr_accessor :quobyte

    # RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md
    attr_accessor :rbd

    # ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.
    attr_accessor :scale_io

    # Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.
    attr_accessor :storage_class_name

    # StorageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://releases.k8s.io/HEAD/examples/volumes/storageos/README.md
    attr_accessor :storageos

    # volumeMode defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state. Value of Filesystem is implied when not included in spec. This is a beta feature.
    attr_accessor :volume_mode

    # VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine
    attr_accessor :vsphere_volume


    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'access_modes' => :'accessModes',
        :'aws_elastic_block_store' => :'awsElasticBlockStore',
        :'azure_disk' => :'azureDisk',
        :'azure_file' => :'azureFile',
        :'capacity' => :'capacity',
        :'cephfs' => :'cephfs',
        :'cinder' => :'cinder',
        :'claim_ref' => :'claimRef',
        :'csi' => :'csi',
        :'fc' => :'fc',
        :'flex_volume' => :'flexVolume',
        :'flocker' => :'flocker',
        :'gce_persistent_disk' => :'gcePersistentDisk',
        :'glusterfs' => :'glusterfs',
        :'host_path' => :'hostPath',
        :'iscsi' => :'iscsi',
        :'local' => :'local',
        :'mount_options' => :'mountOptions',
        :'nfs' => :'nfs',
        :'node_affinity' => :'nodeAffinity',
        :'persistent_volume_reclaim_policy' => :'persistentVolumeReclaimPolicy',
        :'photon_persistent_disk' => :'photonPersistentDisk',
        :'portworx_volume' => :'portworxVolume',
        :'quobyte' => :'quobyte',
        :'rbd' => :'rbd',
        :'scale_io' => :'scaleIO',
        :'storage_class_name' => :'storageClassName',
        :'storageos' => :'storageos',
        :'volume_mode' => :'volumeMode',
        :'vsphere_volume' => :'vsphereVolume'
      }
    end

    # Attribute type mapping.
    def self.swagger_types
      {
        :'access_modes' => :'Array<String>',
        :'aws_elastic_block_store' => :'V1AWSElasticBlockStoreVolumeSource',
        :'azure_disk' => :'V1AzureDiskVolumeSource',
        :'azure_file' => :'V1AzureFilePersistentVolumeSource',
        :'capacity' => :'Hash<String, String>',
        :'cephfs' => :'V1CephFSPersistentVolumeSource',
        :'cinder' => :'V1CinderPersistentVolumeSource',
        :'claim_ref' => :'V1ObjectReference',
        :'csi' => :'V1CSIPersistentVolumeSource',
        :'fc' => :'V1FCVolumeSource',
        :'flex_volume' => :'V1FlexPersistentVolumeSource',
        :'flocker' => :'V1FlockerVolumeSource',
        :'gce_persistent_disk' => :'V1GCEPersistentDiskVolumeSource',
        :'glusterfs' => :'V1GlusterfsPersistentVolumeSource',
        :'host_path' => :'V1HostPathVolumeSource',
        :'iscsi' => :'V1ISCSIPersistentVolumeSource',
        :'local' => :'V1LocalVolumeSource',
        :'mount_options' => :'Array<String>',
        :'nfs' => :'V1NFSVolumeSource',
        :'node_affinity' => :'V1VolumeNodeAffinity',
        :'persistent_volume_reclaim_policy' => :'String',
        :'photon_persistent_disk' => :'V1PhotonPersistentDiskVolumeSource',
        :'portworx_volume' => :'V1PortworxVolumeSource',
        :'quobyte' => :'V1QuobyteVolumeSource',
        :'rbd' => :'V1RBDPersistentVolumeSource',
        :'scale_io' => :'V1ScaleIOPersistentVolumeSource',
        :'storage_class_name' => :'String',
        :'storageos' => :'V1StorageOSPersistentVolumeSource',
        :'volume_mode' => :'String',
        :'vsphere_volume' => :'V1VsphereVirtualDiskVolumeSource'
      }
    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?(:'accessModes')
        if (value = attributes[:'accessModes']).is_a?(Array)
          self.access_modes = value
        end
      end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if attributes.has_key?(:'vsphereVolume')
        self.vsphere_volume = attributes[:'vsphereVolume']
      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
      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 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 &&
          access_modes == o.access_modes &&
          aws_elastic_block_store == o.aws_elastic_block_store &&
          azure_disk == o.azure_disk &&
          azure_file == o.azure_file &&
          capacity == o.capacity &&
          cephfs == o.cephfs &&
          cinder == o.cinder &&
          claim_ref == o.claim_ref &&
          csi == o.csi &&
          fc == o.fc &&
          flex_volume == o.flex_volume &&
          flocker == o.flocker &&
          gce_persistent_disk == o.gce_persistent_disk &&
          glusterfs == o.glusterfs &&
          host_path == o.host_path &&
          iscsi == o.iscsi &&
          local == o.local &&
          mount_options == o.mount_options &&
          nfs == o.nfs &&
          node_affinity == o.node_affinity &&
          persistent_volume_reclaim_policy == o.persistent_volume_reclaim_policy &&
          photon_persistent_disk == o.photon_persistent_disk &&
          portworx_volume == o.portworx_volume &&
          quobyte == o.quobyte &&
          rbd == o.rbd &&
          scale_io == o.scale_io &&
          storage_class_name == o.storage_class_name &&
          storageos == o.storageos &&
          volume_mode == o.volume_mode &&
          vsphere_volume == o.vsphere_volume
    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
      [access_modes, aws_elastic_block_store, azure_disk, azure_file, capacity, cephfs, cinder, claim_ref, csi, fc, flex_volume, flocker, gce_persistent_disk, glusterfs, host_path, iscsi, local, mount_options, nfs, node_affinity, persistent_volume_reclaim_policy, photon_persistent_disk, portworx_volume, quobyte, rbd, scale_io, storage_class_name, storageos, volume_mode, vsphere_volume].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
