Path: blob/main/components/public-api/go/examples/client_example.go
2500 views
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package examples56import (7"context"8"fmt"9"github.com/bufbuild/connect-go"10"github.com/gitpod-io/gitpod/components/public-api/go/client"11v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"12"os"13)1415func ExampleClient() {16token := "gitpod_pat_example.personal-access-token"17gitpod, err := client.New(client.WithCredentials(token))18if err != nil {19fmt.Fprintf(os.Stderr, "Failed to construct gitpod client %v", err)20return21}2223// use the gitpod client to access resources24gitpod.Teams.ListTeams(context.Background(), connect.NewRequest(&v1.ListTeamsRequest{}))25}262728