Sha256: 06914ca68ff66e556b1a8a793e01b1f03bae62608480fe4d23dbd8d6be44b720

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "roseflow/pinecone/response"
require "roseflow/pinecone/structs"

module Roseflow
  module Pinecone
    class Index
      def initialize(connection)
        @connection = connection
      end

      def list
        IndexResponse.new(
          method: :list,
          response: connection.get("/databases")
        )
      end

      def describe(name)
        IndexResponse.new(
          method: :describe,
          response: connection.get("/databases/#{name}")
        )
      end

      def create(name, options = {})
        IndexResponse.new(
          method: :create,
          response: connection.post("/databases", create_payload(name, options))
        )
      end

      def delete(name)
        IndexResponse.new(
          method: :delete,
          response: connection.delete("/databases/#{name}")
        )
      end

      private

      attr_reader :connection

      def create_payload(name, options)
        options.merge({
          name: name
        })
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roseflow-pinecone-0.1.0 lib/roseflow/pinecone/index.rb