Skip to content

Commit

Permalink
Regenerate client code for 2024-10 (#86)
Browse files Browse the repository at this point in the history
## Problem
PR was merged today making some slight adjustments to the db control
spec to better align with the server impl:
pinecone-io/apis#181

## Solution
Slightly adjust the `PodSpec` type and related code to account for the
new shape.

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

## Test Plan
`just test` - CI
  • Loading branch information
austin-denoble authored Oct 23, 2024
1 parent 2bd11c5 commit b669b68
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion codegen/apis
Submodule apis updated from 9d3a41 to 39e90e
14 changes: 11 additions & 3 deletions internal/gen/db_control/db_control_2024-10.oas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions pinecone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest)

deletionProtection := pointerOrNil(db_control.DeletionProtection(in.DeletionProtection))
metric := pointerOrNil(db_control.CreateIndexRequestMetric(in.Metric))
pods := in.TotalCount()
replicas := in.ReplicaCount()
shards := in.ShardCount()

req := db_control.CreateIndexRequest{
Name: in.Name,
Expand All @@ -556,9 +559,9 @@ func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest)
Pod: &db_control.PodSpec{
Environment: in.Environment,
PodType: in.PodType,
Pods: in.TotalCount(),
Replicas: in.ReplicaCount(),
Shards: in.ShardCount(),
Pods: &pods,
Replicas: &replicas,
Shards: &shards,
SourceCollection: in.SourceCollection,
},
}
Expand Down Expand Up @@ -1506,9 +1509,9 @@ func toIndex(idx *db_control.IndexModel) *Index {
spec.Pod = &PodSpec{
Environment: idx.Spec.Pod.Environment,
PodType: idx.Spec.Pod.PodType,
PodCount: int32(idx.Spec.Pod.Pods),
Replicas: idx.Spec.Pod.Replicas,
ShardCount: idx.Spec.Pod.Shards,
PodCount: derefOrDefault(idx.Spec.Pod.Pods, 1),
Replicas: derefOrDefault(idx.Spec.Pod.Replicas, 1),
ShardCount: derefOrDefault(idx.Spec.Pod.Shards, 1),
SourceCollection: idx.Spec.Pod.SourceCollection,
}
if idx.Spec.Pod.MetadataConfig != nil {
Expand Down
9 changes: 6 additions & 3 deletions pinecone/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ func TestEnsureURLSchemeUnit(t *testing.T) {
func TestToIndexUnit(t *testing.T) {
deletionProtectionEnabled := db_control.Enabled
deletionProtectionDisabled := db_control.Disabled
pods := 1
replicas := int32(1)
shards := int32(1)

tests := []struct {
name string
Expand Down Expand Up @@ -999,9 +1002,9 @@ func TestToIndexUnit(t *testing.T) {
}{Pod: &db_control.PodSpec{
Environment: "test-environ",
PodType: "p1.x2",
Pods: 1,
Replicas: 1,
Shards: 1,
Pods: &pods,
Replicas: &replicas,
Shards: &shards,
SourceCollection: nil,
MetadataConfig: nil,
}}),
Expand Down
2 changes: 1 addition & 1 deletion pinecone/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type PodSpecMetadataConfig struct {
type PodSpec struct {
Environment string `json:"environment"`
PodType string `json:"pod_type"`
PodCount int32 `json:"pod_count"`
PodCount int `json:"pod_count"`
Replicas int32 `json:"replicas"`
ShardCount int32 `json:"shard_count"`
SourceCollection *string `json:"source_collection,omitempty"`
Expand Down

0 comments on commit b669b68

Please sign in to comment.