| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
const _ = connect.IsAtLeastVersion1_13_0 |
| 22 |
|
| 23 |
const ( |
| 24 |
|
| 25 |
AuthServiceName = "svc.auth.v1.AuthService" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const ( |
| 36 |
|
| 37 |
AuthServiceGetAuthURLProcedure = "/svc.auth.v1.AuthService/GetAuthURL" |
| 38 |
|
| 39 |
|
| 40 |
AuthServiceBeginDeviceAuthProcedure = "/svc.auth.v1.AuthService/BeginDeviceAuth" |
| 41 |
|
| 42 |
|
| 43 |
AuthServiceCompleteDeviceAuthProcedure = "/svc.auth.v1.AuthService/CompleteDeviceAuth" |
| 44 |
) |
| 45 |
|
| 46 |
|
| 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 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 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 |
|
| 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 |
} |