Skip to content

Commit

Permalink
Sample docstring for Client struct
Browse files Browse the repository at this point in the history
  • Loading branch information
aulorbe committed Jun 20, 2024
1 parent 257e9f6 commit 4974f79
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pinecone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,48 @@ import (
"github.com/pinecone-io/go-pinecone/internal/useragent"
)

// Client provides a high-level interface for interacting with the Pinecone control plane API.
// It encapsulates the necessary authentication, request creation, and response handling for the API's operations.
//
// The Client is designed to be long-lived and reused across multiple operations.
//
// Fields:
// - headers: The HTTP headers you would like attached to your API request.
// - restClient: The underlying REST client used to communicate with the Pinecone control plane API.
// This field is internal and managed by Client.
// - sourceTag: An optional string used to help Pinecone attribute API activity to our partners.
//
// To use Client, first build the parameters of your request using NewClientParams,
// providing your API key. Then pass those parameters into the NewClient function to create a new Client.
// Once instantiated, you can call Client's methods to perform actions such as creating, deleting,
// and describing indexes and collections.
//
// Example:
// ctx := context.Background()
//
// clientParams := pinecone.NewClientParams{
// ApiKey: getEnvVars("PINECONE_API_KEY"),
// SourceTag: "your_source_identifier", // optional
// }
//
// pc, err := pinecone.NewClient(clientParams)
// if err != nil {
// log.Fatalf("Failed to create Client: %v", err)
// }
//
// idxs, err := pc.ListIndexes(ctx)
// if err != nil {
// fmt.Println("Error:", err)
// return
// }
//
// for _, idx := range idxs {
// fmt.Println(idx)
// }
//
// Note that Client methods are designed to be safe for concurrent use by multiple
// goroutines, assuming that its configuration (e.g., the API key) is not modified after
// initialization.
type Client struct {
headers map[string]string
restClient *control.Client
Expand Down

0 comments on commit 4974f79

Please sign in to comment.