Skip to content

Instantly share code, notes, and snippets.

@sinmetal
Created November 13, 2019 03:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinmetal/3482088f9ab73c22aa9415ab3eec7eeb to your computer and use it in GitHub Desktop.
Save sinmetal/3482088f9ab73c22aa9415ab3eec7eeb to your computer and use it in GitHub Desktop.
cloud.google.com/go/spanner/admin sample
package main
import (
"context"
"fmt"
"google.golang.org/genproto/protobuf/field_mask"
instance "cloud.google.com/go/spanner/admin/instance/apiv1"
instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1"
)
func main() {
ctx := context.Background()
UpdateInstance(ctx)
}
func UpdateInstance(ctx context.Context) {
c, err := instance.NewInstanceAdminClient(ctx)
if err != nil {
fmt.Printf("failed new admin client. err=%+v\n", err)
}
req := &instancepb.UpdateInstanceRequest{
Instance: &instancepb.Instance{
Name: fmt.Sprintf("projects/%s/instances/%s", "gcpug-public-spanner", "merpay-sponsored-instance"),
NodeCount: 3,
},
FieldMask: &field_mask.FieldMask{
Paths: []string{"node_count"},
},
}
op, err := c.UpdateInstance(ctx, req)
if err != nil {
fmt.Printf("failed new admin client. err=%+v\n", err)
}
resp, err := op.Wait(ctx)
if err != nil {
fmt.Printf("failed new admin client. err=%+v\n", err)
}
fmt.Printf("resp is %+v\n", resp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment