def to_file(file_path, format = :json)
      format = :yml if %w[.yml .yaml].include? File.extname(file_path)
      temp_data = { type: self.class.name, api_version: @api_version, data: @data }
      case format.to_sym
      when :json
        File.open(file_path, 'w') { |f| f.write(JSON.pretty_generate(temp_data)) }
      when :yml, :yaml
        File.open(file_path, 'w') { |f| f.write(temp_data.to_yaml) }
      else
        raise InvalidFormat, "Invalid format: #{format}"
      end
      true
    end
def to_file(file_path, format = :json)
      format = :yml if %w[.yml .yaml].include? File.extname(file_path)
      temp_data = { type: self.class.name, api_version: @api_version, data: @data }
      case format.to_sym
      when :json
        File.open(file_path, 'w') { |f| f.write(JSON.pretty_generate(temp_data)) }
      when :yml, :yaml
        File.open(file_path, 'w') { |f| f.write(temp_data.to_yaml) }
      else
        raise InvalidFormat, "Invalid format: #{format}"
      end
      true
    end
Save resource to json or yaml file
 @param [String] file_path The full path to the file
 @param [Symbol] format The format. Options: [:json, :yml, :yaml]. Defaults to .json
 @note If a .yml or .yaml file extension is given in the file_path, the format will be set automatically
 @return [True] The Resource was saved successfully