Debian Codegraph @

go/svc/auth/v1/authv1connect/service.connect.go

raw symbols SCIP
1 // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2 //
3 // Source: svc/auth/v1/service.proto
4
5 package authv1connect
6
7 import (
8 connect "connectrpc.com/connect"
9 context "context"
10 errors "errors"
11 v1 "github.com/humanlogio/api/go/svc/auth/v1"
12 http "net/http"
13 strings "strings"
14 )
15
16 // This is a compile-time assertion to ensure that this generated file and the connect package are
17 // compatible. If you get a compiler error that this constant is not defined, this code was
18 // generated with a version of connect newer than the one compiled into your binary. You can fix the
19 // problem by either regenerating this code with an older version of connect or updating the connect
20 // version compiled into your binary.
21 const _ = connect.IsAtLeastVersion1_13_0
22
23 const (
24 // AuthServiceName is the fully-qualified name of the AuthService service.
25 AuthServiceName = "svc.auth.v1.AuthService"
26 )
27
28 // These constants are the fully-qualified names of the RPCs defined in this package. They're
29 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
30 //
31 // Note that these are different from the fully-qualified method names used by
32 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
33 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
34 // period.
35 const (
36 // AuthServiceGetAuthURLProcedure is the fully-qualified name of the AuthService's GetAuthURL RPC.
37 AuthServiceGetAuthURLProcedure = "/svc.auth.v1.AuthService/GetAuthURL"
38 // AuthServiceBeginDeviceAuthProcedure is the fully-qualified name of the AuthService's
39 // BeginDeviceAuth RPC.
40 AuthServiceBeginDeviceAuthProcedure = "/svc.auth.v1.AuthService/BeginDeviceAuth"
41 // AuthServiceCompleteDeviceAuthProcedure is the fully-qualified name of the AuthService's
42 // CompleteDeviceAuth RPC.
43 AuthServiceCompleteDeviceAuthProcedure = "/svc.auth.v1.AuthService/CompleteDeviceAuth"
44 )
45
46 // AuthServiceClient is a client for the svc.auth.v1.AuthService service.
47 type AuthServiceClient interface {
48 GetAuthURL(context.Context, *connect.Request[v1.GetAuthURLRequest]) (*connect.Response[v1.GetAuthURLResponse], error)
49 BeginDeviceAuth(context.Context, *connect.Request[v1.BeginDeviceAuthRequest]) (*connect.Response[v1.BeginDeviceAuthResponse], error)
50 CompleteDeviceAuth(context.Context, *connect.Request[v1.CompleteDeviceAuthRequest]) (*connect.Response[v1.CompleteDeviceAuthResponse], error)
51 }
52
53 // NewAuthServiceClient constructs a client for the svc.auth.v1.AuthService service. By default, it
54 // uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
55 // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
56 // connect.WithGRPCWeb() options.
57 //
58 // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
59 // http://api.acme.com or https://acme.com/grpc).
60 func NewAuthServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthServiceClient {
61 baseURL = strings.TrimRight(baseURL, "/")
62 authServiceMethods := v1.File_svc_auth_v1_service_proto.Services().ByName("AuthService").Methods()
63 return &authServiceClient{
64 getAuthURL: connect.NewClient[v1.GetAuthURLRequest, v1.GetAuthURLResponse](
65 httpClient,
66 baseURL+AuthServiceGetAuthURLProcedure,
67 connect.WithSchema(authServiceMethods.ByName("GetAuthURL")),
68 connect.WithClientOptions(opts...),
69 ),
70 beginDeviceAuth: connect.NewClient[v1.BeginDeviceAuthRequest, v1.BeginDeviceAuthResponse](
71 httpClient,
72 baseURL+AuthServiceBeginDeviceAuthProcedure,
73 connect.WithSchema(authServiceMethods.ByName("BeginDeviceAuth")),
74 connect.WithClientOptions(opts...),
75 ),
76 completeDeviceAuth: connect.NewClient[v1.CompleteDeviceAuthRequest, v1.CompleteDeviceAuthResponse](
77 httpClient,
78 baseURL+AuthServiceCompleteDeviceAuthProcedure,
79 connect.WithSchema(authServiceMethods.ByName("CompleteDeviceAuth")),
80 connect.WithClientOptions(opts...),
81 ),
82 }
83 }
84
85 // authServiceClient implements AuthServiceClient.
86 type authServiceClient struct {
87 getAuthURL *connect.Client[v1.GetAuthURLRequest, v1.GetAuthURLResponse]
88 beginDeviceAuth *connect.Client[v1.BeginDeviceAuthRequest, v1.BeginDeviceAuthResponse]
89 completeDeviceAuth *connect.Client[v1.CompleteDeviceAuthRequest, v1.CompleteDeviceAuthResponse]
90 }
91
92 // GetAuthURL calls svc.auth.v1.AuthService.GetAuthURL.
93 func (c *authServiceClient) GetAuthURL(ctx context.Context, req *connect.Request[v1.GetAuthURLRequest]) (*connect.Response[v1.GetAuthURLResponse], error) {
94 return c.getAuthURL.CallUnary(ctx, req)
95 }
96
97 // BeginDeviceAuth calls svc.auth.v1.AuthService.BeginDeviceAuth.
98 func (c *authServiceClient) BeginDeviceAuth(ctx context.Context, req *connect.Request[v1.BeginDeviceAuthRequest]) (*connect.Response[v1.BeginDeviceAuthResponse], error) {
99 return c.beginDeviceAuth.CallUnary(ctx, req)
100 }
101
102 // CompleteDeviceAuth calls svc.auth.v1.AuthService.CompleteDeviceAuth.
103 func (c *authServiceClient) CompleteDeviceAuth(ctx context.Context, req *connect.Request[v1.CompleteDeviceAuthRequest]) (*connect.Response[v1.CompleteDeviceAuthResponse], error) {
104 return c.completeDeviceAuth.CallUnary(ctx, req)
105 }
106
107 // AuthServiceHandler is an implementation of the svc.auth.v1.AuthService service.
108 type AuthServiceHandler interface {
109 GetAuthURL(context.Context, *connect.Request[v1.GetAuthURLRequest]) (*connect.Response[v1.GetAuthURLResponse], error)
110 BeginDeviceAuth(context.Context, *connect.Request[v1.BeginDeviceAuthRequest]) (*connect.Response[v1.BeginDeviceAuthResponse], error)
111 CompleteDeviceAuth(context.Context, *connect.Request[v1.CompleteDeviceAuthRequest]) (*connect.Response[v1.CompleteDeviceAuthResponse], error)
112 }
113
114 // NewAuthServiceHandler builds an HTTP handler from the service implementation. It returns the path
115 // on which to mount the handler and the handler itself.
116 //
117 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
118 // and JSON codecs. They also support gzip compression.
119 func NewAuthServiceHandler(svc AuthServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
120 authServiceMethods := v1.File_svc_auth_v1_service_proto.Services().ByName("AuthService").Methods()
121 authServiceGetAuthURLHandler := connect.NewUnaryHandler(
122 AuthServiceGetAuthURLProcedure,
123 svc.GetAuthURL,
124 connect.WithSchema(authServiceMethods.ByName("GetAuthURL")),
125 connect.WithHandlerOptions(opts...),
126 )
127 authServiceBeginDeviceAuthHandler := connect.NewUnaryHandler(
128 AuthServiceBeginDeviceAuthProcedure,
129 svc.BeginDeviceAuth,
130 connect.WithSchema(authServiceMethods.ByName("BeginDeviceAuth")),
131 connect.WithHandlerOptions(opts...),
132 )
133 authServiceCompleteDeviceAuthHandler := connect.NewUnaryHandler(
134 AuthServiceCompleteDeviceAuthProcedure,
135 svc.CompleteDeviceAuth,
136 connect.WithSchema(authServiceMethods.ByName("CompleteDeviceAuth")),
137 connect.WithHandlerOptions(opts...),
138 )
139 return "/svc.auth.v1.AuthService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
140 switch r.URL.Path {
141 case AuthServiceGetAuthURLProcedure:
142 authServiceGetAuthURLHandler.ServeHTTP(w, r)
143 case AuthServiceBeginDeviceAuthProcedure:
144 authServiceBeginDeviceAuthHandler.ServeHTTP(w, r)
145 case AuthServiceCompleteDeviceAuthProcedure:
146 authServiceCompleteDeviceAuthHandler.ServeHTTP(w, r)
147 default:
148 http.NotFound(w, r)
149 }
150 })
151 }
152
153 // UnimplementedAuthServiceHandler returns CodeUnimplemented from all methods.
154 type UnimplementedAuthServiceHandler struct{}
155
156 func (UnimplementedAuthServiceHandler) GetAuthURL(context.Context, *connect.Request[v1.GetAuthURLRequest]) (*connect.Response[v1.GetAuthURLResponse], error) {
157 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.auth.v1.AuthService.GetAuthURL is not implemented"))
158 }
159
160 func (UnimplementedAuthServiceHandler) BeginDeviceAuth(context.Context, *connect.Request[v1.BeginDeviceAuthRequest]) (*connect.Response[v1.BeginDeviceAuthResponse], error) {
161 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.auth.v1.AuthService.BeginDeviceAuth is not implemented"))
162 }
163
164 func (UnimplementedAuthServiceHandler) CompleteDeviceAuth(context.Context, *connect.Request[v1.CompleteDeviceAuthRequest]) (*connect.Response[v1.CompleteDeviceAuthResponse], error) {
165 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.auth.v1.AuthService.CompleteDeviceAuth is not implemented"))
166 }