def parse_type(type)
      api_ver = (@options['api_version'] || ENV['ONEVIEWSDK_API_VERSION'] || OneviewSDK.api_version).to_i
      unless OneviewSDK::SUPPORTED_API_VERSIONS.include?(api_ver)
        # Find and use the best available match for the desired API version (round down to nearest)
        valid_api_ver = OneviewSDK::SUPPORTED_API_VERSIONS.select { |x| x <= api_ver }.max || OneviewSDK::SUPPORTED_API_VERSIONS.min
        puts "WARNING: Module API version #{api_ver} is not supported. Using #{valid_api_ver}"
        api_ver = valid_api_ver
      end
      variant = @options['variant'] || ENV['ONEVIEWSDK_VARIANT']
      variant ||= OneviewSDK::API300.variant if api_ver == 300
      if variant && !SUPPORTED_VARIANTS.include?(variant)
        fail_nice "Variant '#{variant}' is not supported. Try one of #{SUPPORTED_VARIANTS}"
      end
      r = OneviewSDK.resource_named(type, api_ver, variant)
      # Try default API version as last resort
      r ||= OneviewSDK.resource_named(type, OneviewSDK.api_version, variant) unless api_ver == OneviewSDK.api_version
      return r if r && r.respond_to?(:find_by)
      valid_classes = []
      api_module = OneviewSDK.const_get("API#{api_ver}")
      api_module = api_module.const_get(variant.to_s) unless api_ver.to_i == 200
      api_module.constants.each do |c|
        klass = api_module.const_get(c)
        next unless klass.is_a?(Class) && klass.respond_to?(:find_by)
        valid_classes.push(klass.name.split('::').last)
      end
      vc = valid_classes.sort_by!(&:downcase).join("\n  ")
      var = variant ? " (variant #{variant})" : ''
      fail_nice("Invalid resource type: '#{type}'.  Valid options for API version #{api_ver}#{var} are:\n  #{vc}")
    end
def parse_type(type)
      api_ver = (@options['api_version'] || ENV['ONEVIEWSDK_API_VERSION'] || OneviewSDK.api_version).to_i
      unless OneviewSDK::SUPPORTED_API_VERSIONS.include?(api_ver)
        # Find and use the best available match for the desired API version (round down to nearest)
        valid_api_ver = OneviewSDK::SUPPORTED_API_VERSIONS.select { |x| x <= api_ver }.max || OneviewSDK::SUPPORTED_API_VERSIONS.min
        puts "WARNING: Module API version #{api_ver} is not supported. Using #{valid_api_ver}"
        api_ver = valid_api_ver
      end
      variant = @options['variant'] || ENV['ONEVIEWSDK_VARIANT']
      variant ||= OneviewSDK::API300.variant if api_ver == 300
      if variant && !SUPPORTED_VARIANTS.include?(variant)
        fail_nice "Variant '#{variant}' is not supported. Try one of #{SUPPORTED_VARIANTS}"
      end
      r = OneviewSDK.resource_named(type, api_ver, variant)
      # Try default API version as last resort
      r ||= OneviewSDK.resource_named(type, OneviewSDK.api_version, variant) unless api_ver == OneviewSDK.api_version
      return r if r && r.respond_to?(:find_by)
      valid_classes = []
      api_module = OneviewSDK.const_get("API#{api_ver}")
      api_module = api_module.const_get(variant.to_s) unless api_ver.to_i == 200
      api_module.constants.each do |c|
        klass = api_module.const_get(c)
        next unless klass.is_a?(Class) && klass.respond_to?(:find_by)
        valid_classes.push(klass.name.split('::').last)
      end
      vc = valid_classes.sort_by!(&:downcase).join("\n  ")
      var = variant ? " (variant #{variant})" : ''
      fail_nice("Invalid resource type: '#{type}'.  Valid options for API version #{api_ver}#{var} are:\n  #{vc}")
    end
Get resource class from given string