user

package
v0.0.0-...-faa3d42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 19 Imported by: 0

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

View Source
const UserPathPrefix = "/twirp/easypay.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

View Source
var Resp_RoleName_name = map[int32]string{
	0: "INVALID",
	1: "SUPER_ADMIN",
	2: "ADMIN",
	3: "TENANT_ADMIN",
	4: "USER",
}
View Source
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) Descriptor() ([]byte, []int)

func (*CreateReq) GetEmail

func (m *CreateReq) GetEmail() string

func (*CreateReq) GetFirstName

func (m *CreateReq) GetFirstName() string

func (*CreateReq) GetLastName

func (m *CreateReq) GetLastName() string

func (*CreateReq) GetPassword

func (m *CreateReq) GetPassword() string

func (*CreateReq) GetRoleId

func (m *CreateReq) GetRoleId() int32

func (*CreateReq) GetTenantId

func (m *CreateReq) GetTenantId() int32

func (*CreateReq) GetUsername

func (m *CreateReq) GetUsername() string

func (*CreateReq) ProtoMessage

func (*CreateReq) ProtoMessage()

func (*CreateReq) Reset

func (m *CreateReq) Reset()

func (*CreateReq) String

func (m *CreateReq) String() string

func (*CreateReq) Validate

func (this *CreateReq) Validate() error

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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) Descriptor() ([]byte, []int)

func (*IDReq) GetID

func (m *IDReq) GetID() int64

func (*IDReq) ProtoMessage

func (*IDReq) ProtoMessage()

func (*IDReq) Reset

func (m *IDReq) Reset()

func (*IDReq) String

func (m *IDReq) String() string

func (*IDReq) Validate

func (this *IDReq) Validate() error

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) Descriptor() ([]byte, []int)

func (*ListReq) GetLimit

func (m *ListReq) GetLimit() int32

func (*ListReq) GetPage

func (m *ListReq) GetPage() int32

func (*ListReq) GetTenantId

func (m *ListReq) GetTenantId() int32

func (*ListReq) ProtoMessage

func (*ListReq) ProtoMessage()

func (*ListReq) Reset

func (m *ListReq) Reset()

func (*ListReq) String

func (m *ListReq) String() string

func (*ListReq) Validate

func (this *ListReq) Validate() error

type ListResp

type ListResp struct {
	Users []*Resp `protobuf:"bytes,1,rep,name=users" json:"users,omitempty"`
}

List response

func (*ListResp) Descriptor

func (*ListResp) Descriptor() ([]byte, []int)

func (*ListResp) GetUsers

func (m *ListResp) GetUsers() []*Resp

func (*ListResp) ProtoMessage

func (*ListResp) ProtoMessage()

func (*ListResp) Reset

func (m *ListResp) Reset()

func (*ListResp) String

func (m *ListResp) String() string

func (*ListResp) Validate

func (this *ListResp) Validate() error

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=easypay.user.Resp_RoleName" json:"role_name,omitempty"`
}

Response

func (*Resp) Descriptor

func (*Resp) Descriptor() ([]byte, []int)

func (*Resp) GetActive

func (m *Resp) GetActive() bool

func (*Resp) GetAddress

func (m *Resp) GetAddress() string

func (*Resp) GetCreatedAt

func (m *Resp) GetCreatedAt() *google_protobuf2.Timestamp

func (*Resp) GetDeletedAt

func (m *Resp) GetDeletedAt() *google_protobuf2.Timestamp

func (*Resp) GetEmail

func (m *Resp) GetEmail() string

func (*Resp) GetFirstName

func (m *Resp) GetFirstName() string

func (*Resp) GetID

func (m *Resp) GetID() int64

func (*Resp) GetLastLogin

func (m *Resp) GetLastLogin() *google_protobuf2.Timestamp

func (*Resp) GetLastName

func (m *Resp) GetLastName() string

func (*Resp) GetLastPasswordChange

func (m *Resp) GetLastPasswordChange() *google_protobuf2.Timestamp

func (*Resp) GetPhone

func (m *Resp) GetPhone() string

func (*Resp) GetRoleName

func (m *Resp) GetRoleName() Resp_RoleName

func (*Resp) GetTenantId

func (m *Resp) GetTenantId() int32

func (*Resp) GetUpdatedAt

func (m *Resp) GetUpdatedAt() *google_protobuf2.Timestamp

func (*Resp) GetUsername

func (m *Resp) GetUsername() string

func (*Resp) ProtoMessage

func (*Resp) ProtoMessage()

func (*Resp) Reset

func (m *Resp) Reset()

func (*Resp) String

func (m *Resp) String() string

func (*Resp) Validate

func (this *Resp) Validate() error

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) Descriptor() ([]byte, []int)

func (*UpdateReq) GetAddress

func (m *UpdateReq) GetAddress() string

func (*UpdateReq) GetFirstName

func (m *UpdateReq) GetFirstName() string

func (*UpdateReq) GetID

func (m *UpdateReq) GetID() int64

func (*UpdateReq) GetLastName

func (m *UpdateReq) GetLastName() string

func (*UpdateReq) GetPhone

func (m *UpdateReq) GetPhone() string

func (*UpdateReq) ProtoMessage

func (*UpdateReq) ProtoMessage()

func (*UpdateReq) Reset

func (m *UpdateReq) Reset()

func (*UpdateReq) String

func (m *UpdateReq) String() string

func (*UpdateReq) Validate

func (this *UpdateReq) Validate() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL