mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
27 lines
788 B
Go
27 lines
788 B
Go
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License.AGPL.txt in the project root for license information.
|
|
|
|
package examples
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/bufbuild/connect-go"
|
|
"github.com/gitpod-io/gitpod/components/public-api/go/client"
|
|
v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"
|
|
"os"
|
|
)
|
|
|
|
func ExampleClient() {
|
|
token := "gitpod_pat_example.personal-access-token"
|
|
gitpod, err := client.New(client.WithCredentials(token))
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Failed to construct gitpod client %v", err)
|
|
return
|
|
}
|
|
|
|
// use the gitpod client to access resources
|
|
gitpod.Teams.ListTeams(context.Background(), connect.NewRequest(&v1.ListTeamsRequest{}))
|
|
}
|