Skip to content

PCU support#49

Merged
bdunn313 merged 8 commits into
mainfrom
PCU-support
Nov 17, 2025
Merged

PCU support#49
bdunn313 merged 8 commits into
mainfrom
PCU-support

Conversation

@bdunn313

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
    }))

resp, _ := client.PcuCreateWithResponse(ctx, []astra.PCUGroupCreateRequest{{
    Title:         "Production PCU Group",
    Region:        "us-east-1",
    Reserved:      100,
    Min:           50,
    Max:           200,
    InstanceType:  "standard",
    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")
}

@emerkle826 emerkle826 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part, these look right, but I would change all the 5XX codes to 500 to be consistent in other places. It looks like auto-generating the client code causes some changes in some places, which will break anything that is using this client and was referencing those codes before.

Comment thread openapi/astra-devops-api.yaml Outdated
Comment thread openapi/astra-devops-api.yaml Outdated
@bdunn313

bdunn313 commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

Related: datastax/terraform-provider-astra#473

@bdunn313 bdunn313 requested a review from emerkle826 November 17, 2025 20:15
@bdunn313

Copy link
Copy Markdown
Contributor Author

Talked this through multiple times in slack etc, addressed comments and tested within TF provider and standalone. Merging and closing.

@bdunn313 bdunn313 merged commit b4df851 into main Nov 17, 2025
1 check passed
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.

2 participants