Skip to content

feat: pcu added into the go client#48

Closed
bdunn313 wants to merge 6 commits into
datastax:mainfrom
bdunn313:feat/provisioned-capacity-units
Closed

feat: pcu added into the go client#48
bdunn313 wants to merge 6 commits into
datastax:mainfrom
bdunn313:feat/provisioned-capacity-units

Conversation

@bdunn313

@bdunn313 bdunn313 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Add in all PCU-related endpoints to the go client

Example: Create a PCU Group

ctx := context.Background()
client, _ := astra.NewClientWithResponses("https://api.astra.datastax.com",
    astra.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
        req.Header.Set("Authorization", "Bearer "+token)
        return nil
    }))

title := "Production PCU Group"
region := "us-east-1"
resp, _ := client.PcuCreateWithResponse(ctx, []astra.PCUGroupCreateRequest{{
    Title:         &title,
    Region:        &region,
    Reserved:      intPtr(100),
    Min:           intPtr(50),
    Max:           intPtr(200),
    InstanceType:  instanceTypePtr(astra.InstanceTypeC532xlarge),
    ProvisionType: provisionTypePtr(astra.ProvisionTypeServerless),
}})

if resp.JSON201 != nil {
    pcuGroupUUID := (*resp.JSON201)[0].Uuid
    fmt.Printf("Created PCU Group: %s\n", *pcuGroupUUID)
}

Example: Get associations and add a new one

resp, _ := client.PcuAssociationGetWithResponse(ctx, "pcu-group-uuid")

if resp.JSON200 != nil {
    for _, assoc := range *resp.JSON200 {
        fmt.Printf("Datacenter: %s, Status: %s\n",
            *assoc.DatacenterUUID, *assoc.ProvisioningStatus)
    }
}

resp, _ := client.PcuAssociationCreateWithResponse(ctx,
    "pcu-group-uuid",
    "datacenter-uuid")

if resp.StatusCode() == 201 {
    fmt.Println("Database associated with PCU group")
}

@bdunn313 bdunn313 marked this pull request as ready for review October 14, 2025 14:57
Comment thread astra/astra.gen.go Outdated
Comment thread astra/astra.gen.go Outdated
@bdunn313 bdunn313 force-pushed the feat/provisioned-capacity-units branch from f807ca8 to 5014f3a Compare October 23, 2025 14:04
@bdunn313 bdunn313 closed this Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant