Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/public-api/go/v1/v1connect/token.connect.go
2501 views
1
// Copyright (c) 2025 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
6
//
7
// Source: gitpod/v1/token.proto
8
9
package v1connect
10
11
import (
12
context "context"
13
errors "errors"
14
connect_go "github.com/bufbuild/connect-go"
15
v1 "github.com/gitpod-io/gitpod/components/public-api/go/v1"
16
http "net/http"
17
strings "strings"
18
)
19
20
// This is a compile-time assertion to ensure that this generated file and the connect package are
21
// compatible. If you get a compiler error that this constant is not defined, this code was
22
// generated with a version of connect newer than the one compiled into your binary. You can fix the
23
// problem by either regenerating this code with an older version of connect or updating the connect
24
// version compiled into your binary.
25
const _ = connect_go.IsAtLeastVersion0_1_0
26
27
const (
28
// TokenServiceName is the fully-qualified name of the TokenService service.
29
TokenServiceName = "gitpod.v1.TokenService"
30
)
31
32
// TokenServiceClient is a client for the gitpod.v1.TokenService service.
33
type TokenServiceClient interface {
34
// CreateUserToken creates a new temporary access token for the specified user.
35
// +admin – only to be used by installation admins
36
CreateTemporaryAccessToken(context.Context, *connect_go.Request[v1.CreateTemporaryAccessTokenRequest]) (*connect_go.Response[v1.CreateTemporaryAccessTokenResponse], error)
37
}
38
39
// NewTokenServiceClient constructs a client for the gitpod.v1.TokenService service. By default, it
40
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
41
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
42
// connect.WithGRPCWeb() options.
43
//
44
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
45
// http://api.acme.com or https://acme.com/grpc).
46
func NewTokenServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) TokenServiceClient {
47
baseURL = strings.TrimRight(baseURL, "/")
48
return &tokenServiceClient{
49
createTemporaryAccessToken: connect_go.NewClient[v1.CreateTemporaryAccessTokenRequest, v1.CreateTemporaryAccessTokenResponse](
50
httpClient,
51
baseURL+"/gitpod.v1.TokenService/CreateTemporaryAccessToken",
52
opts...,
53
),
54
}
55
}
56
57
// tokenServiceClient implements TokenServiceClient.
58
type tokenServiceClient struct {
59
createTemporaryAccessToken *connect_go.Client[v1.CreateTemporaryAccessTokenRequest, v1.CreateTemporaryAccessTokenResponse]
60
}
61
62
// CreateTemporaryAccessToken calls gitpod.v1.TokenService.CreateTemporaryAccessToken.
63
func (c *tokenServiceClient) CreateTemporaryAccessToken(ctx context.Context, req *connect_go.Request[v1.CreateTemporaryAccessTokenRequest]) (*connect_go.Response[v1.CreateTemporaryAccessTokenResponse], error) {
64
return c.createTemporaryAccessToken.CallUnary(ctx, req)
65
}
66
67
// TokenServiceHandler is an implementation of the gitpod.v1.TokenService service.
68
type TokenServiceHandler interface {
69
// CreateUserToken creates a new temporary access token for the specified user.
70
// +admin – only to be used by installation admins
71
CreateTemporaryAccessToken(context.Context, *connect_go.Request[v1.CreateTemporaryAccessTokenRequest]) (*connect_go.Response[v1.CreateTemporaryAccessTokenResponse], error)
72
}
73
74
// NewTokenServiceHandler builds an HTTP handler from the service implementation. It returns the
75
// path on which to mount the handler and the handler itself.
76
//
77
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
78
// and JSON codecs. They also support gzip compression.
79
func NewTokenServiceHandler(svc TokenServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
80
mux := http.NewServeMux()
81
mux.Handle("/gitpod.v1.TokenService/CreateTemporaryAccessToken", connect_go.NewUnaryHandler(
82
"/gitpod.v1.TokenService/CreateTemporaryAccessToken",
83
svc.CreateTemporaryAccessToken,
84
opts...,
85
))
86
return "/gitpod.v1.TokenService/", mux
87
}
88
89
// UnimplementedTokenServiceHandler returns CodeUnimplemented from all methods.
90
type UnimplementedTokenServiceHandler struct{}
91
92
func (UnimplementedTokenServiceHandler) CreateTemporaryAccessToken(context.Context, *connect_go.Request[v1.CreateTemporaryAccessTokenRequest]) (*connect_go.Response[v1.CreateTemporaryAccessTokenResponse], error) {
93
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("gitpod.v1.TokenService.CreateTemporaryAccessToken is not implemented"))
94
}
95
96