blob: 724d2a62f0cda47057330ac03e4d908289b3c743 [file] [log] [blame]
// Copyright 2020-2021 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-twirp v7.1.0, DO NOT EDIT.
// source: buf/alpha/registry/v1alpha1/user.proto
package registryv1alpha1
import bytes "bytes"
import strings "strings"
import context "context"
import fmt "fmt"
import ioutil "io/ioutil"
import http "net/http"
import strconv "strconv"
import jsonpb "github.com/golang/protobuf/jsonpb"
import proto "github.com/golang/protobuf/proto"
import twirp "github.com/twitchtv/twirp"
import ctxsetters "github.com/twitchtv/twirp/ctxsetters"
// This is a compile-time assertion to ensure that this generated file
// is compatible with the twirp package used in your project.
// A compilation error at this line likely means your copy of the
// twirp package needs to be updated.
const _ = twirp.TwirpPackageIsVersion7
// =====================
// UserService Interface
// =====================
// UserService is the User service.
type UserService interface {
// CreateUser creates a new user with the given username.
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
// GetUser gets a user by ID.
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
// GetUserByUsername gets a user by username.
GetUserByUsername(context.Context, *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error)
// ListUsers lists all users.
ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)
// ListOrganizationUsers lists all users for an organization.
ListOrganizationUsers(context.Context, *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error)
// UpdateUserUsername updates a user's username.
UpdateUserUsername(context.Context, *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error)
// DeleteUser deletes a user.
DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error)
// AddUserOrganizationScope adds an organization scope for a specific organization to a user by ID.
AddUserOrganizationScope(context.Context, *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error)
// AddUserOrganizationScopeByName adds an organization scope for a specific organization to a user by name.
AddUserOrganizationScopeByName(context.Context, *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error)
// RemoveUserOrganizationScope removes an organization scope for a specific organization from a user by ID.
RemoveUserOrganizationScope(context.Context, *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error)
// RemoveUserOrganizationScopeByName removes an organization scope for a specific organization from a user by name.
RemoveUserOrganizationScopeByName(context.Context, *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error)
// AddUserServerScope adds a server scope for a user by ID.
AddUserServerScope(context.Context, *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error)
// AddUserServerScopeByName adds a server scope for a user by name.
AddUserServerScopeByName(context.Context, *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error)
// RemoveUserServerScope removes a server scope for a user by ID.
RemoveUserServerScope(context.Context, *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error)
// RemoveUserServerScopeByName removes a server scope for a user by name.
RemoveUserServerScopeByName(context.Context, *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error)
}
// ===========================
// UserService Protobuf Client
// ===========================
type userServiceProtobufClient struct {
client HTTPClient
urls [15]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
// NewUserServiceProtobufClient creates a Protobuf client that implements the UserService interface.
// It communicates using Protobuf and can be configured with a custom HTTPClient.
func NewUserServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) UserService {
if c, ok := client.(*http.Client); ok {
client = withoutRedirects(c)
}
clientOpts := twirp.ClientOptions{}
for _, o := range opts {
o(&clientOpts)
}
// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(clientOpts.PathPrefix(), "buf.alpha.registry.v1alpha1", "UserService")
urls := [15]string{
serviceURL + "CreateUser",
serviceURL + "GetUser",
serviceURL + "GetUserByUsername",
serviceURL + "ListUsers",
serviceURL + "ListOrganizationUsers",
serviceURL + "UpdateUserUsername",
serviceURL + "DeleteUser",
serviceURL + "AddUserOrganizationScope",
serviceURL + "AddUserOrganizationScopeByName",
serviceURL + "RemoveUserOrganizationScope",
serviceURL + "RemoveUserOrganizationScopeByName",
serviceURL + "AddUserServerScope",
serviceURL + "AddUserServerScopeByName",
serviceURL + "RemoveUserServerScope",
serviceURL + "RemoveUserServerScopeByName",
}
return &userServiceProtobufClient{
client: client,
urls: urls,
interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
opts: clientOpts,
}
}
func (c *userServiceProtobufClient) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "CreateUser")
caller := c.callCreateUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*CreateUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*CreateUserRequest) when calling interceptor")
}
return c.callCreateUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*CreateUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*CreateUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callCreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) {
out := new(CreateUserResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "GetUser")
caller := c.callGetUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetUserRequest) (*GetUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserRequest) when calling interceptor")
}
return c.callGetUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callGetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) {
out := new(GetUserResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) GetUserByUsername(ctx context.Context, in *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "GetUserByUsername")
caller := c.callGetUserByUsername
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserByUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserByUsernameRequest) when calling interceptor")
}
return c.callGetUserByUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserByUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserByUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callGetUserByUsername(ctx context.Context, in *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
out := new(GetUserByUsernameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "ListUsers")
caller := c.callListUsers
if c.interceptor != nil {
caller = func(ctx context.Context, req *ListUsersRequest) (*ListUsersResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListUsersRequest) when calling interceptor")
}
return c.callListUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) {
out := new(ListUsersResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) ListOrganizationUsers(ctx context.Context, in *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "ListOrganizationUsers")
caller := c.callListOrganizationUsers
if c.interceptor != nil {
caller = func(ctx context.Context, req *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListOrganizationUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListOrganizationUsersRequest) when calling interceptor")
}
return c.callListOrganizationUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListOrganizationUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListOrganizationUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callListOrganizationUsers(ctx context.Context, in *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
out := new(ListOrganizationUsersResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) UpdateUserUsername(ctx context.Context, in *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "UpdateUserUsername")
caller := c.callUpdateUserUsername
if c.interceptor != nil {
caller = func(ctx context.Context, req *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*UpdateUserUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*UpdateUserUsernameRequest) when calling interceptor")
}
return c.callUpdateUserUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*UpdateUserUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*UpdateUserUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callUpdateUserUsername(ctx context.Context, in *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
out := new(UpdateUserUsernameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "DeleteUser")
caller := c.callDeleteUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *DeleteUserRequest) (*DeleteUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*DeleteUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*DeleteUserRequest) when calling interceptor")
}
return c.callDeleteUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*DeleteUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*DeleteUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callDeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) {
out := new(DeleteUserResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) AddUserOrganizationScope(ctx context.Context, in *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScope")
caller := c.callAddUserOrganizationScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeRequest) when calling interceptor")
}
return c.callAddUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callAddUserOrganizationScope(ctx context.Context, in *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
out := new(AddUserOrganizationScopeResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) AddUserOrganizationScopeByName(ctx context.Context, in *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScopeByName")
caller := c.callAddUserOrganizationScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeByNameRequest) when calling interceptor")
}
return c.callAddUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callAddUserOrganizationScopeByName(ctx context.Context, in *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
out := new(AddUserOrganizationScopeByNameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) RemoveUserOrganizationScope(ctx context.Context, in *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScope")
caller := c.callRemoveUserOrganizationScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeRequest) when calling interceptor")
}
return c.callRemoveUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callRemoveUserOrganizationScope(ctx context.Context, in *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
out := new(RemoveUserOrganizationScopeResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) RemoveUserOrganizationScopeByName(ctx context.Context, in *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScopeByName")
caller := c.callRemoveUserOrganizationScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeByNameRequest) when calling interceptor")
}
return c.callRemoveUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callRemoveUserOrganizationScopeByName(ctx context.Context, in *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
out := new(RemoveUserOrganizationScopeByNameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[10], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) AddUserServerScope(ctx context.Context, in *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScope")
caller := c.callAddUserServerScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeRequest) when calling interceptor")
}
return c.callAddUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callAddUserServerScope(ctx context.Context, in *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
out := new(AddUserServerScopeResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[11], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) AddUserServerScopeByName(ctx context.Context, in *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScopeByName")
caller := c.callAddUserServerScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeByNameRequest) when calling interceptor")
}
return c.callAddUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callAddUserServerScopeByName(ctx context.Context, in *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
out := new(AddUserServerScopeByNameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[12], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) RemoveUserServerScope(ctx context.Context, in *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScope")
caller := c.callRemoveUserServerScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeRequest) when calling interceptor")
}
return c.callRemoveUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callRemoveUserServerScope(ctx context.Context, in *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
out := new(RemoveUserServerScopeResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[13], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceProtobufClient) RemoveUserServerScopeByName(ctx context.Context, in *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScopeByName")
caller := c.callRemoveUserServerScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeByNameRequest) when calling interceptor")
}
return c.callRemoveUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceProtobufClient) callRemoveUserServerScopeByName(ctx context.Context, in *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
out := new(RemoveUserServerScopeByNameResponse)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[14], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
// =======================
// UserService JSON Client
// =======================
type userServiceJSONClient struct {
client HTTPClient
urls [15]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
// NewUserServiceJSONClient creates a JSON client that implements the UserService interface.
// It communicates using JSON and can be configured with a custom HTTPClient.
func NewUserServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) UserService {
if c, ok := client.(*http.Client); ok {
client = withoutRedirects(c)
}
clientOpts := twirp.ClientOptions{}
for _, o := range opts {
o(&clientOpts)
}
// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(clientOpts.PathPrefix(), "buf.alpha.registry.v1alpha1", "UserService")
urls := [15]string{
serviceURL + "CreateUser",
serviceURL + "GetUser",
serviceURL + "GetUserByUsername",
serviceURL + "ListUsers",
serviceURL + "ListOrganizationUsers",
serviceURL + "UpdateUserUsername",
serviceURL + "DeleteUser",
serviceURL + "AddUserOrganizationScope",
serviceURL + "AddUserOrganizationScopeByName",
serviceURL + "RemoveUserOrganizationScope",
serviceURL + "RemoveUserOrganizationScopeByName",
serviceURL + "AddUserServerScope",
serviceURL + "AddUserServerScopeByName",
serviceURL + "RemoveUserServerScope",
serviceURL + "RemoveUserServerScopeByName",
}
return &userServiceJSONClient{
client: client,
urls: urls,
interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
opts: clientOpts,
}
}
func (c *userServiceJSONClient) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "CreateUser")
caller := c.callCreateUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*CreateUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*CreateUserRequest) when calling interceptor")
}
return c.callCreateUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*CreateUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*CreateUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callCreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) {
out := new(CreateUserResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "GetUser")
caller := c.callGetUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetUserRequest) (*GetUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserRequest) when calling interceptor")
}
return c.callGetUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callGetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) {
out := new(GetUserResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) GetUserByUsername(ctx context.Context, in *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "GetUserByUsername")
caller := c.callGetUserByUsername
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserByUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserByUsernameRequest) when calling interceptor")
}
return c.callGetUserByUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserByUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserByUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callGetUserByUsername(ctx context.Context, in *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
out := new(GetUserByUsernameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "ListUsers")
caller := c.callListUsers
if c.interceptor != nil {
caller = func(ctx context.Context, req *ListUsersRequest) (*ListUsersResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListUsersRequest) when calling interceptor")
}
return c.callListUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) {
out := new(ListUsersResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) ListOrganizationUsers(ctx context.Context, in *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "ListOrganizationUsers")
caller := c.callListOrganizationUsers
if c.interceptor != nil {
caller = func(ctx context.Context, req *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListOrganizationUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListOrganizationUsersRequest) when calling interceptor")
}
return c.callListOrganizationUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListOrganizationUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListOrganizationUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callListOrganizationUsers(ctx context.Context, in *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
out := new(ListOrganizationUsersResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) UpdateUserUsername(ctx context.Context, in *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "UpdateUserUsername")
caller := c.callUpdateUserUsername
if c.interceptor != nil {
caller = func(ctx context.Context, req *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*UpdateUserUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*UpdateUserUsernameRequest) when calling interceptor")
}
return c.callUpdateUserUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*UpdateUserUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*UpdateUserUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callUpdateUserUsername(ctx context.Context, in *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
out := new(UpdateUserUsernameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "DeleteUser")
caller := c.callDeleteUser
if c.interceptor != nil {
caller = func(ctx context.Context, req *DeleteUserRequest) (*DeleteUserResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*DeleteUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*DeleteUserRequest) when calling interceptor")
}
return c.callDeleteUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*DeleteUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*DeleteUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callDeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) {
out := new(DeleteUserResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) AddUserOrganizationScope(ctx context.Context, in *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScope")
caller := c.callAddUserOrganizationScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeRequest) when calling interceptor")
}
return c.callAddUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callAddUserOrganizationScope(ctx context.Context, in *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
out := new(AddUserOrganizationScopeResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) AddUserOrganizationScopeByName(ctx context.Context, in *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScopeByName")
caller := c.callAddUserOrganizationScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeByNameRequest) when calling interceptor")
}
return c.callAddUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callAddUserOrganizationScopeByName(ctx context.Context, in *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
out := new(AddUserOrganizationScopeByNameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) RemoveUserOrganizationScope(ctx context.Context, in *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScope")
caller := c.callRemoveUserOrganizationScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeRequest) when calling interceptor")
}
return c.callRemoveUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callRemoveUserOrganizationScope(ctx context.Context, in *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
out := new(RemoveUserOrganizationScopeResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) RemoveUserOrganizationScopeByName(ctx context.Context, in *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScopeByName")
caller := c.callRemoveUserOrganizationScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeByNameRequest) when calling interceptor")
}
return c.callRemoveUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callRemoveUserOrganizationScopeByName(ctx context.Context, in *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
out := new(RemoveUserOrganizationScopeByNameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[10], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) AddUserServerScope(ctx context.Context, in *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScope")
caller := c.callAddUserServerScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeRequest) when calling interceptor")
}
return c.callAddUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callAddUserServerScope(ctx context.Context, in *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
out := new(AddUserServerScopeResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[11], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) AddUserServerScopeByName(ctx context.Context, in *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScopeByName")
caller := c.callAddUserServerScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeByNameRequest) when calling interceptor")
}
return c.callAddUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callAddUserServerScopeByName(ctx context.Context, in *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
out := new(AddUserServerScopeByNameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[12], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) RemoveUserServerScope(ctx context.Context, in *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScope")
caller := c.callRemoveUserServerScope
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeRequest) when calling interceptor")
}
return c.callRemoveUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callRemoveUserServerScope(ctx context.Context, in *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
out := new(RemoveUserServerScopeResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[13], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *userServiceJSONClient) RemoveUserServerScopeByName(ctx context.Context, in *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScopeByName")
caller := c.callRemoveUserServerScopeByName
if c.interceptor != nil {
caller = func(ctx context.Context, req *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeByNameRequest) when calling interceptor")
}
return c.callRemoveUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *userServiceJSONClient) callRemoveUserServerScopeByName(ctx context.Context, in *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
out := new(RemoveUserServerScopeByNameResponse)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[14], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
// ==========================
// UserService Server Handler
// ==========================
type userServiceServer struct {
UserService
interceptor twirp.Interceptor
hooks *twirp.ServerHooks
pathPrefix string // prefix for routing
jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response
}
// NewUserServiceServer builds a TwirpServer that can be used as an http.Handler to handle
// HTTP requests that are routed to the right method in the provided svc implementation.
// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).
func NewUserServiceServer(svc UserService, opts ...interface{}) TwirpServer {
serverOpts := twirp.ServerOptions{}
for _, opt := range opts {
switch o := opt.(type) {
case twirp.ServerOption:
o(&serverOpts)
case *twirp.ServerHooks: // backwards compatibility, allow to specify hooks as an argument
twirp.WithServerHooks(o)(&serverOpts)
case nil: // backwards compatibility, allow nil value for the argument
continue
default:
panic(fmt.Sprintf("Invalid option type %T on NewUserServiceServer", o))
}
}
return &userServiceServer{
UserService: svc,
pathPrefix: serverOpts.PathPrefix(),
interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...),
hooks: serverOpts.Hooks,
jsonSkipDefaults: serverOpts.JSONSkipDefaults,
}
}
// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks.
// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
func (s *userServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) {
writeError(ctx, resp, err, s.hooks)
}
// UserServicePathPrefix is a convenience constant that could used to identify URL paths.
// Should be used with caution, it only matches routes generated by Twirp Go clients,
// that add a "/twirp" prefix by default, and use CamelCase service and method names.
// More info: https://twitchtv.github.io/twirp/docs/routing.html
const UserServicePathPrefix = "/twirp/buf.alpha.registry.v1alpha1.UserService/"
func (s *userServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
ctx := req.Context()
ctx = ctxsetters.WithPackageName(ctx, "buf.alpha.registry.v1alpha1")
ctx = ctxsetters.WithServiceName(ctx, "UserService")
ctx = ctxsetters.WithResponseWriter(ctx, resp)
var err error
ctx, err = callRequestReceived(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
if req.Method != "POST" {
msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
// Verify path format: [<prefix>]/<package>.<Service>/<Method>
prefix, pkgService, method := parseTwirpPath(req.URL.Path)
if pkgService != "buf.alpha.registry.v1alpha1.UserService" {
msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
if prefix != s.pathPrefix {
msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
switch method {
case "CreateUser":
s.serveCreateUser(ctx, resp, req)
return
case "GetUser":
s.serveGetUser(ctx, resp, req)
return
case "GetUserByUsername":
s.serveGetUserByUsername(ctx, resp, req)
return
case "ListUsers":
s.serveListUsers(ctx, resp, req)
return
case "ListOrganizationUsers":
s.serveListOrganizationUsers(ctx, resp, req)
return
case "UpdateUserUsername":
s.serveUpdateUserUsername(ctx, resp, req)
return
case "DeleteUser":
s.serveDeleteUser(ctx, resp, req)
return
case "AddUserOrganizationScope":
s.serveAddUserOrganizationScope(ctx, resp, req)
return
case "AddUserOrganizationScopeByName":
s.serveAddUserOrganizationScopeByName(ctx, resp, req)
return
case "RemoveUserOrganizationScope":
s.serveRemoveUserOrganizationScope(ctx, resp, req)
return
case "RemoveUserOrganizationScopeByName":
s.serveRemoveUserOrganizationScopeByName(ctx, resp, req)
return
case "AddUserServerScope":
s.serveAddUserServerScope(ctx, resp, req)
return
case "AddUserServerScopeByName":
s.serveAddUserServerScopeByName(ctx, resp, req)
return
case "RemoveUserServerScope":
s.serveRemoveUserServerScope(ctx, resp, req)
return
case "RemoveUserServerScopeByName":
s.serveRemoveUserServerScopeByName(ctx, resp, req)
return
default:
msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
}
func (s *userServiceServer) serveCreateUser(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCreateUserJSON(ctx, resp, req)
case "application/protobuf":
s.serveCreateUserProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveCreateUserJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(CreateUserRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.CreateUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*CreateUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*CreateUserRequest) when calling interceptor")
}
return s.UserService.CreateUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*CreateUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*CreateUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *CreateUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *CreateUserResponse and nil error while calling CreateUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveCreateUserProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(CreateUserRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.CreateUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*CreateUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*CreateUserRequest) when calling interceptor")
}
return s.UserService.CreateUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*CreateUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*CreateUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *CreateUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *CreateUserResponse and nil error while calling CreateUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveGetUser(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveGetUserJSON(ctx, resp, req)
case "application/protobuf":
s.serveGetUserProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveGetUserJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(GetUserRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.GetUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetUserRequest) (*GetUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserRequest) when calling interceptor")
}
return s.UserService.GetUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *GetUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *GetUserResponse and nil error while calling GetUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveGetUserProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(GetUserRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.GetUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetUserRequest) (*GetUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserRequest) when calling interceptor")
}
return s.UserService.GetUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *GetUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *GetUserResponse and nil error while calling GetUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveGetUserByUsername(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveGetUserByUsernameJSON(ctx, resp, req)
case "application/protobuf":
s.serveGetUserByUsernameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveGetUserByUsernameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetUserByUsername")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(GetUserByUsernameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.GetUserByUsername
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserByUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserByUsernameRequest) when calling interceptor")
}
return s.UserService.GetUserByUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserByUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserByUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *GetUserByUsernameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *GetUserByUsernameResponse and nil error while calling GetUserByUsername. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveGetUserByUsernameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetUserByUsername")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(GetUserByUsernameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.GetUserByUsername
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetUserByUsernameRequest) (*GetUserByUsernameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetUserByUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetUserByUsernameRequest) when calling interceptor")
}
return s.UserService.GetUserByUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*GetUserByUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*GetUserByUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *GetUserByUsernameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *GetUserByUsernameResponse and nil error while calling GetUserByUsername. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveListUsers(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveListUsersJSON(ctx, resp, req)
case "application/protobuf":
s.serveListUsersProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveListUsersJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListUsers")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(ListUsersRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.ListUsers
if s.interceptor != nil {
handler = func(ctx context.Context, req *ListUsersRequest) (*ListUsersResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListUsersRequest) when calling interceptor")
}
return s.UserService.ListUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *ListUsersResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ListUsersResponse and nil error while calling ListUsers. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveListUsersProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListUsers")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(ListUsersRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.ListUsers
if s.interceptor != nil {
handler = func(ctx context.Context, req *ListUsersRequest) (*ListUsersResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListUsersRequest) when calling interceptor")
}
return s.UserService.ListUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *ListUsersResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ListUsersResponse and nil error while calling ListUsers. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveListOrganizationUsers(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveListOrganizationUsersJSON(ctx, resp, req)
case "application/protobuf":
s.serveListOrganizationUsersProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveListOrganizationUsersJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListOrganizationUsers")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(ListOrganizationUsersRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.ListOrganizationUsers
if s.interceptor != nil {
handler = func(ctx context.Context, req *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListOrganizationUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListOrganizationUsersRequest) when calling interceptor")
}
return s.UserService.ListOrganizationUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListOrganizationUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListOrganizationUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *ListOrganizationUsersResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ListOrganizationUsersResponse and nil error while calling ListOrganizationUsers. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveListOrganizationUsersProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListOrganizationUsers")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(ListOrganizationUsersRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.ListOrganizationUsers
if s.interceptor != nil {
handler = func(ctx context.Context, req *ListOrganizationUsersRequest) (*ListOrganizationUsersResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ListOrganizationUsersRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ListOrganizationUsersRequest) when calling interceptor")
}
return s.UserService.ListOrganizationUsers(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ListOrganizationUsersResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ListOrganizationUsersResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *ListOrganizationUsersResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ListOrganizationUsersResponse and nil error while calling ListOrganizationUsers. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveUpdateUserUsername(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveUpdateUserUsernameJSON(ctx, resp, req)
case "application/protobuf":
s.serveUpdateUserUsernameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveUpdateUserUsernameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "UpdateUserUsername")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(UpdateUserUsernameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.UpdateUserUsername
if s.interceptor != nil {
handler = func(ctx context.Context, req *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*UpdateUserUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*UpdateUserUsernameRequest) when calling interceptor")
}
return s.UserService.UpdateUserUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*UpdateUserUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*UpdateUserUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *UpdateUserUsernameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *UpdateUserUsernameResponse and nil error while calling UpdateUserUsername. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveUpdateUserUsernameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "UpdateUserUsername")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(UpdateUserUsernameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.UpdateUserUsername
if s.interceptor != nil {
handler = func(ctx context.Context, req *UpdateUserUsernameRequest) (*UpdateUserUsernameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*UpdateUserUsernameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*UpdateUserUsernameRequest) when calling interceptor")
}
return s.UserService.UpdateUserUsername(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*UpdateUserUsernameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*UpdateUserUsernameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *UpdateUserUsernameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *UpdateUserUsernameResponse and nil error while calling UpdateUserUsername. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveDeleteUser(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveDeleteUserJSON(ctx, resp, req)
case "application/protobuf":
s.serveDeleteUserProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveDeleteUserJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(DeleteUserRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.DeleteUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *DeleteUserRequest) (*DeleteUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*DeleteUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*DeleteUserRequest) when calling interceptor")
}
return s.UserService.DeleteUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*DeleteUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*DeleteUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *DeleteUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *DeleteUserResponse and nil error while calling DeleteUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveDeleteUserProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteUser")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(DeleteUserRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.DeleteUser
if s.interceptor != nil {
handler = func(ctx context.Context, req *DeleteUserRequest) (*DeleteUserResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*DeleteUserRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*DeleteUserRequest) when calling interceptor")
}
return s.UserService.DeleteUser(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*DeleteUserResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*DeleteUserResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *DeleteUserResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *DeleteUserResponse and nil error while calling DeleteUser. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserOrganizationScope(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveAddUserOrganizationScopeJSON(ctx, resp, req)
case "application/protobuf":
s.serveAddUserOrganizationScopeProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveAddUserOrganizationScopeJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(AddUserOrganizationScopeRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.AddUserOrganizationScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeRequest) when calling interceptor")
}
return s.UserService.AddUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserOrganizationScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserOrganizationScopeResponse and nil error while calling AddUserOrganizationScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserOrganizationScopeProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(AddUserOrganizationScopeRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.AddUserOrganizationScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserOrganizationScopeRequest) (*AddUserOrganizationScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeRequest) when calling interceptor")
}
return s.UserService.AddUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserOrganizationScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserOrganizationScopeResponse and nil error while calling AddUserOrganizationScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserOrganizationScopeByName(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveAddUserOrganizationScopeByNameJSON(ctx, resp, req)
case "application/protobuf":
s.serveAddUserOrganizationScopeByNameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveAddUserOrganizationScopeByNameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(AddUserOrganizationScopeByNameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.AddUserOrganizationScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeByNameRequest) when calling interceptor")
}
return s.UserService.AddUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserOrganizationScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserOrganizationScopeByNameResponse and nil error while calling AddUserOrganizationScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserOrganizationScopeByNameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserOrganizationScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(AddUserOrganizationScopeByNameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.AddUserOrganizationScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserOrganizationScopeByNameRequest) (*AddUserOrganizationScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserOrganizationScopeByNameRequest) when calling interceptor")
}
return s.UserService.AddUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserOrganizationScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserOrganizationScopeByNameResponse and nil error while calling AddUserOrganizationScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserOrganizationScope(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveRemoveUserOrganizationScopeJSON(ctx, resp, req)
case "application/protobuf":
s.serveRemoveUserOrganizationScopeProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveRemoveUserOrganizationScopeJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(RemoveUserOrganizationScopeRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.RemoveUserOrganizationScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeRequest) when calling interceptor")
}
return s.UserService.RemoveUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserOrganizationScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserOrganizationScopeResponse and nil error while calling RemoveUserOrganizationScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserOrganizationScopeProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(RemoveUserOrganizationScopeRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.RemoveUserOrganizationScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserOrganizationScopeRequest) (*RemoveUserOrganizationScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeRequest) when calling interceptor")
}
return s.UserService.RemoveUserOrganizationScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserOrganizationScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserOrganizationScopeResponse and nil error while calling RemoveUserOrganizationScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserOrganizationScopeByName(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveRemoveUserOrganizationScopeByNameJSON(ctx, resp, req)
case "application/protobuf":
s.serveRemoveUserOrganizationScopeByNameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveRemoveUserOrganizationScopeByNameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(RemoveUserOrganizationScopeByNameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.RemoveUserOrganizationScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeByNameRequest) when calling interceptor")
}
return s.UserService.RemoveUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserOrganizationScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserOrganizationScopeByNameResponse and nil error while calling RemoveUserOrganizationScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserOrganizationScopeByNameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserOrganizationScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(RemoveUserOrganizationScopeByNameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.RemoveUserOrganizationScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserOrganizationScopeByNameRequest) (*RemoveUserOrganizationScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserOrganizationScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserOrganizationScopeByNameRequest) when calling interceptor")
}
return s.UserService.RemoveUserOrganizationScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserOrganizationScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserOrganizationScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserOrganizationScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserOrganizationScopeByNameResponse and nil error while calling RemoveUserOrganizationScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserServerScope(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveAddUserServerScopeJSON(ctx, resp, req)
case "application/protobuf":
s.serveAddUserServerScopeProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveAddUserServerScopeJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(AddUserServerScopeRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.AddUserServerScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeRequest) when calling interceptor")
}
return s.UserService.AddUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserServerScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserServerScopeResponse and nil error while calling AddUserServerScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserServerScopeProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(AddUserServerScopeRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.AddUserServerScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserServerScopeRequest) (*AddUserServerScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeRequest) when calling interceptor")
}
return s.UserService.AddUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserServerScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserServerScopeResponse and nil error while calling AddUserServerScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserServerScopeByName(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveAddUserServerScopeByNameJSON(ctx, resp, req)
case "application/protobuf":
s.serveAddUserServerScopeByNameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveAddUserServerScopeByNameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(AddUserServerScopeByNameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.AddUserServerScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeByNameRequest) when calling interceptor")
}
return s.UserService.AddUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserServerScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserServerScopeByNameResponse and nil error while calling AddUserServerScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveAddUserServerScopeByNameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "AddUserServerScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(AddUserServerScopeByNameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.AddUserServerScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *AddUserServerScopeByNameRequest) (*AddUserServerScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*AddUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*AddUserServerScopeByNameRequest) when calling interceptor")
}
return s.UserService.AddUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*AddUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*AddUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *AddUserServerScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *AddUserServerScopeByNameResponse and nil error while calling AddUserServerScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserServerScope(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveRemoveUserServerScopeJSON(ctx, resp, req)
case "application/protobuf":
s.serveRemoveUserServerScopeProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveRemoveUserServerScopeJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(RemoveUserServerScopeRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.RemoveUserServerScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeRequest) when calling interceptor")
}
return s.UserService.RemoveUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserServerScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserServerScopeResponse and nil error while calling RemoveUserServerScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserServerScopeProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScope")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(RemoveUserServerScopeRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.RemoveUserServerScope
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserServerScopeRequest) (*RemoveUserServerScopeResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeRequest) when calling interceptor")
}
return s.UserService.RemoveUserServerScope(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserServerScopeResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserServerScopeResponse and nil error while calling RemoveUserServerScope. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserServerScopeByName(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveRemoveUserServerScopeByNameJSON(ctx, resp, req)
case "application/protobuf":
s.serveRemoveUserServerScopeByNameProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *userServiceServer) serveRemoveUserServerScopeByNameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
reqContent := new(RemoveUserServerScopeByNameRequest)
unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true}
if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded"))
return
}
handler := s.UserService.RemoveUserServerScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeByNameRequest) when calling interceptor")
}
return s.UserService.RemoveUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserServerScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserServerScopeByNameResponse and nil error while calling RemoveUserServerScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
var buf bytes.Buffer
marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults}
if err = marshaler.Marshal(&buf, respContent); err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
respBytes := buf.Bytes()
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) serveRemoveUserServerScopeByNameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "RemoveUserServerScopeByName")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to read request body"))
return
}
reqContent := new(RemoveUserServerScopeByNameRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.UserService.RemoveUserServerScopeByName
if s.interceptor != nil {
handler = func(ctx context.Context, req *RemoveUserServerScopeByNameRequest) (*RemoveUserServerScopeByNameResponse, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*RemoveUserServerScopeByNameRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*RemoveUserServerScopeByNameRequest) when calling interceptor")
}
return s.UserService.RemoveUserServerScopeByName(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*RemoveUserServerScopeByNameResponse)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*RemoveUserServerScopeByNameResponse) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *RemoveUserServerScopeByNameResponse
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveUserServerScopeByNameResponse and nil error while calling RemoveUserServerScopeByName. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *userServiceServer) ServiceDescriptor() ([]byte, int) {
return twirpFileDescriptor8, 0
}
func (s *userServiceServer) ProtocGenTwirpVersion() string {
return "v7.1.0"
}
// PathPrefix returns the base service path, in the form: "/<prefix>/<package>.<Service>/"
// that is everything in a Twirp route except for the <Method>. This can be used for routing,
// for example to identify the requests that are targeted to this service in a mux.
func (s *userServiceServer) PathPrefix() string {
return baseServicePath(s.pathPrefix, "buf.alpha.registry.v1alpha1", "UserService")
}
var twirpFileDescriptor8 = []byte{
// 1062 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xdf, 0x6f, 0xdb, 0x54,
0x14, 0xd6, 0x4d, 0x03, 0x6b, 0x4f, 0xb6, 0x76, 0xb9, 0x80, 0x94, 0xba, 0x2d, 0x4d, 0x8d, 0xd6,
0x05, 0x15, 0x6c, 0xad, 0x68, 0x9b, 0x60, 0xc0, 0x46, 0xc7, 0x4f, 0x0d, 0x01, 0x4a, 0xd7, 0x97,
0x09, 0x14, 0x39, 0xcd, 0xad, 0x6b, 0x48, 0x6c, 0xe3, 0x6b, 0x67, 0x6b, 0x79, 0x41, 0x48, 0x48,
0x93, 0x78, 0x45, 0xe2, 0x69, 0xaf, 0x48, 0x48, 0x48, 0xbc, 0x82, 0xc4, 0x3b, 0x12, 0x7f, 0x15,
0xba, 0xd7, 0x76, 0xec, 0x1b, 0xdb, 0xd7, 0x6e, 0x02, 0x43, 0x7d, 0x8b, 0x8f, 0xbf, 0x73, 0xce,
0x77, 0xce, 0xb9, 0xe7, 0xfa, 0x53, 0x60, 0xbb, 0x1f, 0x1c, 0xe9, 0xc6, 0xd0, 0x3d, 0x36, 0x74,
0x8f, 0x98, 0x16, 0xf5, 0xbd, 0x13, 0x7d, 0x7c, 0x8d, 0x1b, 0xae, 0xe9, 0x01, 0x25, 0x9e, 0xe6,
0x7a, 0x8e, 0xef, 0xe0, 0xb5, 0x7e, 0x70, 0xa4, 0x71, 0xb3, 0x16, 0xe3, 0xb4, 0x18, 0xa7, 0xb4,
0x93, 0x20, 0x86, 0x6b, 0x25, 0xfe, 0x86, 0x6b, 0x85, 0xee, 0xca, 0x55, 0x59, 0x1a, 0x7a, 0xe8,
0xb8, 0x24, 0x02, 0x6e, 0x9a, 0x8e, 0x63, 0x0e, 0x89, 0xce, 0x9f, 0x98, 0x93, 0x6f, 0x8d, 0x08,
0xf5, 0x8d, 0x91, 0x1b, 0x02, 0xd4, 0x5f, 0x11, 0xd4, 0x0f, 0x28, 0xf1, 0xf0, 0x32, 0xd4, 0xac,
0x41, 0x0b, 0xb5, 0x51, 0x67, 0xa9, 0x5b, 0xb3, 0x06, 0xf8, 0x16, 0x34, 0x0e, 0x3d, 0x62, 0xf8,
0xa4, 0xc7, 0x5c, 0x5a, 0xb5, 0x36, 0xea, 0x34, 0x76, 0x15, 0x2d, 0x8c, 0xa7, 0xc5, 0xf1, 0xb4,
0xfb, 0x71, 0xbc, 0x2e, 0x84, 0x70, 0x66, 0x60, 0xce, 0x81, 0x3b, 0x98, 0x38, 0x2f, 0x94, 0x3b,
0x87, 0x70, 0xee, 0xac, 0xc0, 0x22, 0xeb, 0x94, 0x6d, 0x8c, 0x48, 0xab, 0xce, 0xf9, 0x4c, 0x9e,
0x55, 0x1d, 0x9a, 0x77, 0x79, 0x1a, 0xc6, 0xb9, 0x4b, 0xbe, 0x0e, 0x08, 0xf5, 0x05, 0x07, 0x34,
0xe5, 0x70, 0x0f, 0x70, 0xda, 0x81, 0xba, 0x8e, 0x4d, 0x09, 0xbe, 0x0e, 0x75, 0x86, 0xe0, 0xe8,
0xc6, 0xee, 0x96, 0x26, 0x99, 0x86, 0xc6, 0x1d, 0x39, 0x5c, 0x6d, 0xc3, 0xf2, 0x07, 0xc4, 0x4f,
0xa7, 0x9e, 0xea, 0x9a, 0xfa, 0x21, 0xac, 0x4c, 0x10, 0xf3, 0xe5, 0xba, 0x01, 0xad, 0x28, 0xd2,
0xde, 0xc9, 0x41, 0x54, 0x4d, 0x95, 0x82, 0xbb, 0xb0, 0x9a, 0xe3, 0x37, 0x1f, 0x97, 0x63, 0xb8,
0xfc, 0xb1, 0x45, 0x79, 0x50, 0x1a, 0x73, 0x58, 0x83, 0x25, 0xd7, 0x30, 0x49, 0x8f, 0x5a, 0xa7,
0x21, 0x89, 0x4b, 0xdd, 0x45, 0x66, 0xd8, 0xb7, 0x4e, 0x09, 0xde, 0x00, 0xe0, 0x2f, 0x7d, 0xe7,
0x2b, 0x62, 0xf3, 0xb3, 0xb3, 0xd4, 0xe5, 0xf0, 0xfb, 0xcc, 0x80, 0x5b, 0x70, 0xc1, 0x23, 0x63,
0xe2, 0xd1, 0xf0, 0x68, 0x2c, 0x76, 0xe3, 0x47, 0xd5, 0x87, 0x66, 0x2a, 0x53, 0xc4, 0xfa, 0x26,
0x3c, 0xc3, 0x68, 0xd0, 0x16, 0x6a, 0x2f, 0x54, 0xa3, 0x1d, 0xe2, 0xf1, 0x36, 0xac, 0xd8, 0xe4,
0x91, 0xdf, 0xcb, 0x70, 0xb9, 0xc4, 0xcc, 0x9f, 0xc5, 0x7c, 0xd4, 0x27, 0x08, 0xd6, 0x59, 0xda,
0x4f, 0x3d, 0xd3, 0xb0, 0xad, 0x53, 0xc3, 0xb7, 0x1c, 0x5b, 0x28, 0xf6, 0x2a, 0xac, 0x38, 0xa9,
0x77, 0xbd, 0xc9, 0xcc, 0x97, 0xd3, 0xe6, 0x8f, 0x06, 0x62, 0x57, 0x6a, 0xd2, 0xae, 0x2c, 0x48,
0xba, 0x52, 0x17, 0xbb, 0xf2, 0x2d, 0x82, 0x8d, 0x02, 0x7e, 0x4f, 0xab, 0x45, 0x6f, 0xc3, 0xea,
0x01, 0x5f, 0x51, 0xe6, 0x3c, 0x7d, 0x1e, 0xb7, 0xe0, 0xa2, 0x4d, 0x1e, 0xf6, 0xa6, 0xce, 0x64,
0xc3, 0x26, 0x0f, 0x63, 0xa4, 0xba, 0x0f, 0x4a, 0x9e, 0xff, 0x7c, 0xe7, 0xf2, 0x39, 0x68, 0xbe,
0x4b, 0x86, 0x44, 0xb8, 0x0d, 0xd4, 0xe7, 0x01, 0xa7, 0x8d, 0x61, 0x06, 0xf5, 0x0f, 0x04, 0x9b,
0xef, 0x0c, 0x06, 0xcc, 0x96, 0xee, 0xe2, 0x3e, 0xbb, 0x2b, 0x0b, 0x96, 0x39, 0x6f, 0xea, 0xb5,
0xdc, 0xa9, 0x7f, 0x01, 0x58, 0x00, 0xf2, 0x1b, 0x98, 0x0f, 0x78, 0x79, 0x57, 0x93, 0x16, 0x93,
0xe5, 0xd2, 0x74, 0xa6, 0x4d, 0xaa, 0x0a, 0xed, 0x62, 0xea, 0x51, 0x7d, 0x7f, 0x21, 0xb8, 0x52,
0x04, 0xda, 0x3b, 0xf9, 0x24, 0x35, 0x2c, 0x0c, 0xf5, 0xd4, 0x90, 0xf8, 0x6f, 0xbc, 0x03, 0x42,
0xda, 0x1e, 0x07, 0x84, 0xb5, 0x5e, 0x4e, 0xbf, 0x60, 0x71, 0xfe, 0xeb, 0x6a, 0x3b, 0xb0, 0x5d,
0x56, 0x48, 0x54, 0xf3, 0x9f, 0x08, 0xd4, 0x2e, 0x19, 0x39, 0x63, 0x72, 0x2e, 0xc7, 0x7a, 0x05,
0x5e, 0x92, 0xb2, 0x8f, 0xaa, 0xfc, 0x1b, 0x41, 0x47, 0x82, 0x3b, 0x5f, 0xc3, 0xdd, 0x81, 0x97,
0x2b, 0xd4, 0x12, 0x55, 0xfe, 0x08, 0x56, 0xa3, 0x93, 0xb0, 0x4f, 0xbc, 0x31, 0xf1, 0xa4, 0x53,
0xbd, 0x07, 0x17, 0x29, 0x47, 0x45, 0x94, 0x6b, 0x9c, 0x72, 0x47, 0x4a, 0x39, 0x1d, 0xb6, 0x41,
0x93, 0x07, 0x75, 0x1d, 0x94, 0xbc, 0xcc, 0x11, 0xaf, 0xef, 0x92, 0xbb, 0x24, 0xf5, 0xba, 0x7c,
0x10, 0xff, 0x2a, 0xc5, 0xe4, 0x52, 0xc8, 0xe1, 0x10, 0x11, 0xfd, 0x06, 0xd6, 0x93, 0x6e, 0x3f,
0xed, 0x1e, 0x6e, 0xc2, 0x46, 0x41, 0xf2, 0x88, 0xdd, 0xf7, 0xc2, 0xfa, 0xfe, 0x7f, 0x9d, 0x14,
0xf6, 0xb0, 0xb0, 0x99, 0xbb, 0xbf, 0x34, 0xa1, 0x11, 0x23, 0xac, 0x43, 0x82, 0x29, 0x40, 0xa2,
0x2c, 0xb1, 0x7c, 0x37, 0x32, 0x9a, 0x55, 0xd1, 0x2b, 0xe3, 0xa3, 0x6e, 0xd5, 0x1f, 0xff, 0xa4,
0xd6, 0xf0, 0x97, 0x70, 0x21, 0x52, 0x77, 0x78, 0x47, 0x1a, 0x41, 0xd4, 0xa9, 0xca, 0x2b, 0xd5,
0xc0, 0xa9, 0x5c, 0x08, 0x3f, 0x46, 0xd0, 0xcc, 0x48, 0x49, 0x7c, 0xbd, 0x4a, 0xa4, 0x8c, 0x64,
0x55, 0x6e, 0x9c, 0xd5, 0x4d, 0xa0, 0xe2, 0xc2, 0xd2, 0x44, 0x16, 0xe2, 0x57, 0xa5, 0xa1, 0xa6,
0x85, 0xaa, 0xa2, 0x55, 0x85, 0x0b, 0x19, 0x7f, 0x44, 0xf0, 0x42, 0xae, 0xe4, 0xc2, 0xaf, 0x97,
0xc6, 0x2b, 0x92, 0x91, 0xca, 0x1b, 0xb3, 0xb8, 0x0a, 0xb4, 0x7e, 0x40, 0x80, 0xb3, 0x3a, 0x0a,
0xcb, 0xbb, 0x5b, 0x28, 0xdc, 0x94, 0x9b, 0x67, 0xf6, 0x13, 0x4e, 0x23, 0x05, 0x48, 0xa4, 0x56,
0xc9, 0x0a, 0x64, 0x84, 0x5a, 0xc9, 0x0a, 0xe4, 0x68, 0xb8, 0x30, 0xe9, 0x13, 0x04, 0xad, 0x22,
0x81, 0x80, 0xdf, 0x94, 0xc6, 0x2c, 0x11, 0x80, 0xca, 0x5b, 0x33, 0x7a, 0x0b, 0xfc, 0x7e, 0x43,
0xf0, 0xa2, 0x5c, 0xc0, 0xe0, 0xbd, 0x99, 0xf2, 0x08, 0xd7, 0xa2, 0x72, 0x77, 0xae, 0x18, 0x02,
0xe3, 0x9f, 0x11, 0xac, 0x49, 0xbe, 0xca, 0xf8, 0xb6, 0x34, 0x55, 0xb9, 0x02, 0x53, 0xee, 0xcc,
0x1e, 0x40, 0x20, 0xfa, 0x3b, 0x82, 0xad, 0x52, 0xf9, 0x80, 0xdf, 0x9b, 0x35, 0x9b, 0xd8, 0xe0,
0xf7, 0xe7, 0x0d, 0x23, 0x50, 0x67, 0x8b, 0x9b, 0xfd, 0x5e, 0x97, 0x2c, 0x6e, 0xa1, 0xfa, 0x29,
0x59, 0x5c, 0x89, 0x76, 0xc9, 0xec, 0x50, 0xe6, 0x83, 0x57, 0x6d, 0x87, 0x8a, 0x3e, 0xd7, 0xd5,
0x76, 0xa8, 0x58, 0xb2, 0x84, 0xfc, 0xd8, 0xed, 0x9b, 0xfb, 0x4d, 0x2e, 0xb9, 0x7d, 0x65, 0x6a,
0xa7, 0xe4, 0xf6, 0x95, 0x6b, 0x95, 0xbc, 0x45, 0xc9, 0x76, 0xee, 0xf6, 0xd9, 0x33, 0x88, 0xcd,
0xbb, 0x33, 0x7b, 0x80, 0x34, 0xd1, 0xbd, 0xcf, 0x1f, 0x3c, 0x30, 0x2d, 0xff, 0x38, 0xe8, 0x6b,
0x87, 0xce, 0x48, 0xef, 0x07, 0x47, 0xfd, 0xc0, 0x1a, 0x0e, 0xd8, 0x0f, 0xdd, 0xb2, 0x7d, 0x76,
0x97, 0x0f, 0x75, 0x93, 0xd8, 0xe1, 0xdf, 0x82, 0xba, 0xe9, 0xe8, 0x92, 0xff, 0x13, 0x6f, 0xc5,
0x96, 0xd8, 0xd0, 0x7f, 0x96, 0xbb, 0xbd, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, 0x4e,
0xf3, 0x47, 0xed, 0x14, 0x00, 0x00,
}