Documentation
¶
Overview ¶
Package user is a generated protocol buffer package.
It is generated from these files:
rpc/user/service.proto
It has these top-level messages:
CreateReq Resp IDReq ListResp ListReq UpdateReq MessageResp
Package user is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.4.1.
It is generated from these files:
rpc/user/service.proto
Package user is a generated protocol buffer package.
It is generated from these files:
rpc/user/service.proto
It has these top-level messages:
CreateReq Resp IDReq ListResp ListReq UpdateReq MessageResp
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type CreateReq
- func (*CreateReq) Descriptor() ([]byte, []int)
- func (m *CreateReq) GetEmail() string
- func (m *CreateReq) GetFirstName() string
- func (m *CreateReq) GetLastName() string
- func (m *CreateReq) GetPassword() string
- func (m *CreateReq) GetRoleId() int32
- func (m *CreateReq) GetTenantId() int32
- func (m *CreateReq) GetUsername() string
- func (*CreateReq) ProtoMessage()
- func (m *CreateReq) Reset()
- func (m *CreateReq) String() string
- func (this *CreateReq) Validate() error
- type HTTPClient
- type IDReq
- type ListReq
- type ListResp
- type MessageResp
- type Resp
- func (*Resp) Descriptor() ([]byte, []int)
- func (m *Resp) GetActive() bool
- func (m *Resp) GetAddress() string
- func (m *Resp) GetCreatedAt() *google_protobuf2.Timestamp
- func (m *Resp) GetDeletedAt() *google_protobuf2.Timestamp
- func (m *Resp) GetEmail() string
- func (m *Resp) GetFirstName() string
- func (m *Resp) GetID() int64
- func (m *Resp) GetLastLogin() *google_protobuf2.Timestamp
- func (m *Resp) GetLastName() string
- func (m *Resp) GetLastPasswordChange() *google_protobuf2.Timestamp
- func (m *Resp) GetPhone() string
- func (m *Resp) GetRoleName() Resp_RoleName
- func (m *Resp) GetTenantId() int32
- func (m *Resp) GetUpdatedAt() *google_protobuf2.Timestamp
- func (m *Resp) GetUsername() string
- func (*Resp) ProtoMessage()
- func (m *Resp) Reset()
- func (m *Resp) String() string
- func (this *Resp) Validate() error
- type Resp_RoleName
- type TwirpServer
- type UpdateReq
- func (*UpdateReq) Descriptor() ([]byte, []int)
- func (m *UpdateReq) GetAddress() string
- func (m *UpdateReq) GetFirstName() string
- func (m *UpdateReq) GetID() int64
- func (m *UpdateReq) GetLastName() string
- func (m *UpdateReq) GetPhone() string
- func (*UpdateReq) ProtoMessage()
- func (m *UpdateReq) Reset()
- func (m *UpdateReq) String() string
- func (this *UpdateReq) Validate() error
- type User
Constants ¶
const UserPathPrefix = "/twirp/twisk.user.User/"
UserPathPrefix is used for all URL paths on a twirp User server. Requests are always: POST UserPathPrefix/method It can be used in an HTTP mux to route twirp requests along with non-twirp requests on other routes.
Variables ¶
var Resp_RoleName_name = map[int32]string{
0: "INVALID",
1: "SUPER_ADMIN",
2: "ADMIN",
3: "TENANT_ADMIN",
4: "USER",
}
var Resp_RoleName_value = map[string]int32{
"INVALID": 0,
"SUPER_ADMIN": 1,
"ADMIN": 2,
"TENANT_ADMIN": 3,
"USER": 4,
}
Functions ¶
func WriteError ¶
func WriteError(resp http.ResponseWriter, err error)
WriteError writes an HTTP response with a valid Twirp error format. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
Types ¶
type CreateReq ¶
type CreateReq struct { // Required. Username represents user's unique username. Must be at least 3 and at most 20 characters. // Can contain only alphanumeric characters, dot and underscore. // Username cannot start with dot or underscore, and cannot have those characters consecutively Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"` // Required. Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"` // Required. FirstName string `protobuf:"bytes,3,opt,name=first_name,json=firstName" json:"first_name,omitempty"` // Required. LastName string `protobuf:"bytes,4,opt,name=last_name,json=lastName" json:"last_name,omitempty"` // Required. Password string `protobuf:"bytes,5,opt,name=password" json:"password,omitempty"` RoleId int32 `protobuf:"varint,6,opt,name=role_id,json=roleId" json:"role_id,omitempty"` TenantId int32 `protobuf:"varint,7,opt,name=tenant_id,json=tenantId" json:"tenant_id,omitempty"` }
Create request
func (*CreateReq) Descriptor ¶
func (*CreateReq) GetFirstName ¶
func (*CreateReq) GetLastName ¶
func (*CreateReq) GetPassword ¶
func (*CreateReq) GetTenantId ¶
func (*CreateReq) GetUsername ¶
func (*CreateReq) ProtoMessage ¶
func (*CreateReq) ProtoMessage()
type HTTPClient ¶
HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.
HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.
type IDReq ¶
type IDReq struct {
ID int64 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"`
}
ID request
func (*IDReq) Descriptor ¶
func (*IDReq) ProtoMessage ¶
func (*IDReq) ProtoMessage()
type ListReq ¶
type ListReq struct { Page int32 `protobuf:"varint,1,opt,name=page" json:"page,omitempty"` Limit int32 `protobuf:"varint,2,opt,name=limit" json:"limit,omitempty"` TenantId int32 `protobuf:"varint,3,opt,name=tenant_id,json=tenantId" json:"tenant_id,omitempty"` }
List request
func (*ListReq) Descriptor ¶
func (*ListReq) GetTenantId ¶
func (*ListReq) ProtoMessage ¶
func (*ListReq) ProtoMessage()
type ListResp ¶
type ListResp struct {
Users []*Resp `protobuf:"bytes,1,rep,name=users" json:"users,omitempty"`
}
List response
func (*ListResp) Descriptor ¶
func (*ListResp) ProtoMessage ¶
func (*ListResp) ProtoMessage()
type MessageResp ¶
type MessageResp struct {
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}
Message response
func (*MessageResp) Descriptor ¶
func (*MessageResp) Descriptor() ([]byte, []int)
func (*MessageResp) GetMessage ¶
func (m *MessageResp) GetMessage() string
func (*MessageResp) ProtoMessage ¶
func (*MessageResp) ProtoMessage()
func (*MessageResp) Reset ¶
func (m *MessageResp) Reset()
func (*MessageResp) String ¶
func (m *MessageResp) String() string
func (*MessageResp) Validate ¶
func (this *MessageResp) Validate() error
type Resp ¶
type Resp struct { ID int64 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` Username string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"` Email string `protobuf:"bytes,3,opt,name=email" json:"email,omitempty"` FirstName string `protobuf:"bytes,4,opt,name=first_name,json=firstName" json:"first_name,omitempty"` LastName string `protobuf:"bytes,5,opt,name=last_name,json=lastName" json:"last_name,omitempty"` Phone string `protobuf:"bytes,6,opt,name=phone" json:"phone,omitempty"` Address string `protobuf:"bytes,7,opt,name=address" json:"address,omitempty"` Active bool `protobuf:"varint,8,opt,name=active" json:"active,omitempty"` TenantId int32 `protobuf:"varint,10,opt,name=tenant_id,json=tenantId" json:"tenant_id,omitempty"` CreatedAt *google_protobuf2.Timestamp `protobuf:"bytes,11,opt,name=created_at,json=createdAt" json:"created_at,omitempty"` UpdatedAt *google_protobuf2.Timestamp `protobuf:"bytes,12,opt,name=updated_at,json=updatedAt" json:"updated_at,omitempty"` DeletedAt *google_protobuf2.Timestamp `protobuf:"bytes,13,opt,name=deleted_at,json=deletedAt" json:"deleted_at,omitempty"` LastLogin *google_protobuf2.Timestamp `protobuf:"bytes,14,opt,name=last_login,json=lastLogin" json:"last_login,omitempty"` LastPasswordChange *google_protobuf2.Timestamp `protobuf:"bytes,15,opt,name=last_password_change,json=lastPasswordChange" json:"last_password_change,omitempty"` RoleName Resp_RoleName `protobuf:"varint,16,opt,name=role_name,json=roleName,enum=twisk.user.Resp_RoleName" json:"role_name,omitempty"` }
Response
func (*Resp) Descriptor ¶
func (*Resp) GetAddress ¶
func (*Resp) GetCreatedAt ¶
func (m *Resp) GetCreatedAt() *google_protobuf2.Timestamp
func (*Resp) GetDeletedAt ¶
func (m *Resp) GetDeletedAt() *google_protobuf2.Timestamp
func (*Resp) GetFirstName ¶
func (*Resp) GetLastLogin ¶
func (m *Resp) GetLastLogin() *google_protobuf2.Timestamp
func (*Resp) GetLastName ¶
func (*Resp) GetLastPasswordChange ¶
func (m *Resp) GetLastPasswordChange() *google_protobuf2.Timestamp
func (*Resp) GetRoleName ¶
func (m *Resp) GetRoleName() Resp_RoleName
func (*Resp) GetTenantId ¶
func (*Resp) GetUpdatedAt ¶
func (m *Resp) GetUpdatedAt() *google_protobuf2.Timestamp
func (*Resp) GetUsername ¶
func (*Resp) ProtoMessage ¶
func (*Resp) ProtoMessage()
type Resp_RoleName ¶
type Resp_RoleName int32
const ( Resp_INVALID Resp_RoleName = 0 Resp_SUPER_ADMIN Resp_RoleName = 1 Resp_ADMIN Resp_RoleName = 2 Resp_TENANT_ADMIN Resp_RoleName = 3 Resp_USER Resp_RoleName = 4 )
func (Resp_RoleName) EnumDescriptor ¶
func (Resp_RoleName) EnumDescriptor() ([]byte, []int)
func (Resp_RoleName) String ¶
func (x Resp_RoleName) String() string
type TwirpServer ¶
type TwirpServer interface { http.Handler // ServiceDescriptor returns gzipped bytes describing the .proto file that // this service was generated from. Once unzipped, the bytes can be // unmarshalled as a // github.com/golang/protobuf/protoc-gen-go/descriptor.FileDescriptorProto. // // The returned integer is the index of this particular service within that // FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a // low-level field, expected to be used for reflection. ServiceDescriptor() ([]byte, int) // ProtocGenTwirpVersion is the semantic version string of the version of // twirp used to generate this file. ProtocGenTwirpVersion() string }
TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.
func NewUserServer ¶
func NewUserServer(svc User, hooks *twirp.ServerHooks) TwirpServer
type UpdateReq ¶
type UpdateReq struct { ID int64 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` FirstName string `protobuf:"bytes,2,opt,name=first_name,json=firstName" json:"first_name,omitempty"` LastName string `protobuf:"bytes,3,opt,name=last_name,json=lastName" json:"last_name,omitempty"` Phone string `protobuf:"bytes,4,opt,name=phone" json:"phone,omitempty"` Address string `protobuf:"bytes,5,opt,name=address" json:"address,omitempty"` }
Update request
func (*UpdateReq) Descriptor ¶
func (*UpdateReq) GetAddress ¶
func (*UpdateReq) GetFirstName ¶
func (*UpdateReq) GetLastName ¶
func (*UpdateReq) ProtoMessage ¶
func (*UpdateReq) ProtoMessage()
type User ¶
type User interface { // Create creates a new user. // In order to create a new user, the authority requesting it must be logged and have same or higher permissions. Create(context.Context, *CreateReq) (*Resp, error) // View views a single user. // User requesting it must be an admin or under same tenant. View(context.Context, *IDReq) (*Resp, error) // List lists all users belonging to the same tenant. List(context.Context, *ListReq) (*ListResp, error) // Update updates a single user. Update(context.Context, *UpdateReq) (*Resp, error) // Delete deletes a user Delete(context.Context, *IDReq) (*MessageResp, error) }
User service handles user crud
func NewUserJSONClient ¶
func NewUserJSONClient(addr string, client HTTPClient) User
NewUserJSONClient creates a JSON client that implements the User interface. It communicates using JSON and can be configured with a custom HTTPClient.
func NewUserProtobufClient ¶
func NewUserProtobufClient(addr string, client HTTPClient) User
NewUserProtobufClient creates a Protobuf client that implements the User interface. It communicates using Protobuf and can be configured with a custom HTTPClient.