*: remove api and clt
It's not clear that the best way to manage clients is through a gRPC based command line tool. For example we may explore an admin dashboard and enable bootstrapping through static clients. For now use static clients while we hold off on a more concrete proposal.
This commit is contained in:
parent
3ca56e32ce
commit
31082eed27
7 changed files with 6 additions and 708 deletions
9
Makefile
9
Makefile
|
@ -46,13 +46,6 @@ lint:
|
||||||
golint $$package; \
|
golint $$package; \
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO(ericchiang): Grab protoc as well.
|
|
||||||
grpc: bin/protoc-gen-go
|
|
||||||
@protoc --go_out=plugins=grpc:. ./api/apipb/*.proto
|
|
||||||
|
|
||||||
bin/protoc-gen-go:
|
|
||||||
@go install ${REPO_PATH}/vendor/github.com/golang/protobuf/protoc-gen-go
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm bin/*
|
@rm bin/*
|
||||||
|
|
||||||
|
@ -60,4 +53,4 @@ testall: testrace vet fmt lint
|
||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
.PHONY: test testrace vet fmt lint testall grpc
|
.PHONY: test testrace vet fmt lint testall
|
||||||
|
|
136
api/api.go
136
api/api.go
|
@ -1,136 +0,0 @@
|
||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
|
|
||||||
"github.com/coreos/poke/api/apipb"
|
|
||||||
"github.com/coreos/poke/storage"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewServer returns a gRPC server for talking to a storage.
|
|
||||||
func NewServer(s storage.Storage) apipb.StorageServer {
|
|
||||||
return &server{s}
|
|
||||||
}
|
|
||||||
|
|
||||||
type server struct {
|
|
||||||
storage storage.Storage
|
|
||||||
}
|
|
||||||
|
|
||||||
func fromPBClient(client *apipb.Client) storage.Client {
|
|
||||||
return storage.Client{
|
|
||||||
ID: client.Id,
|
|
||||||
Secret: client.Secret,
|
|
||||||
RedirectURIs: client.RedirectUris,
|
|
||||||
TrustedPeers: client.TrustedPeers,
|
|
||||||
Public: client.Public,
|
|
||||||
Name: client.Name,
|
|
||||||
LogoURL: client.LogoUrl,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func toPBClient(client storage.Client) *apipb.Client {
|
|
||||||
return &apipb.Client{
|
|
||||||
Id: client.ID,
|
|
||||||
Secret: client.Secret,
|
|
||||||
RedirectUris: client.RedirectURIs,
|
|
||||||
TrustedPeers: client.TrustedPeers,
|
|
||||||
Public: client.Public,
|
|
||||||
Name: client.Name,
|
|
||||||
LogoUrl: client.LogoURL,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) CreateClient(ctx context.Context, req *apipb.CreateClientReq) (*apipb.CreateClientResp, error) {
|
|
||||||
// TODO(ericchiang): Create a more centralized strategy for creating client IDs
|
|
||||||
// and secrets which are restricted based on the storage.
|
|
||||||
client := fromPBClient(req.Client)
|
|
||||||
if client.ID == "" {
|
|
||||||
client.ID = storage.NewID()
|
|
||||||
}
|
|
||||||
if client.Secret == "" {
|
|
||||||
client.Secret = storage.NewID() + storage.NewID()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.storage.CreateClient(client); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &apipb.CreateClientResp{Client: toPBClient(client)}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) UpdateClient(ctx context.Context, req *apipb.UpdateClientReq) (*apipb.UpdateClientResp, error) {
|
|
||||||
switch {
|
|
||||||
case req.Id == "":
|
|
||||||
return nil, errors.New("no ID supplied")
|
|
||||||
case req.MakePublic && req.MakePrivate:
|
|
||||||
return nil, errors.New("cannot both make public and private")
|
|
||||||
case req.MakePublic && len(req.RedirectUris) != 0:
|
|
||||||
return nil, errors.New("redirect uris supplied for a public client")
|
|
||||||
}
|
|
||||||
|
|
||||||
var client *storage.Client
|
|
||||||
updater := func(old storage.Client) (storage.Client, error) {
|
|
||||||
if req.MakePublic {
|
|
||||||
old.Public = true
|
|
||||||
}
|
|
||||||
if req.MakePrivate {
|
|
||||||
old.Public = false
|
|
||||||
}
|
|
||||||
if req.Secret != "" {
|
|
||||||
old.Secret = req.Secret
|
|
||||||
}
|
|
||||||
if req.Name != "" {
|
|
||||||
old.Name = req.Name
|
|
||||||
}
|
|
||||||
if req.LogoUrl != "" {
|
|
||||||
old.LogoURL = req.LogoUrl
|
|
||||||
}
|
|
||||||
if len(req.RedirectUris) != 0 {
|
|
||||||
if old.Public {
|
|
||||||
return old, errors.New("public clients cannot have redirect URIs")
|
|
||||||
}
|
|
||||||
old.RedirectURIs = req.RedirectUris
|
|
||||||
}
|
|
||||||
client = &old
|
|
||||||
return old, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.storage.UpdateClient(req.Id, updater); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &apipb.UpdateClientResp{Client: toPBClient(*client)}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) DeleteClient(ctx context.Context, req *apipb.DeleteClientReq) (*apipb.DeleteClientReq, error) {
|
|
||||||
if req.Id == "" {
|
|
||||||
return nil, errors.New("no client ID supplied")
|
|
||||||
}
|
|
||||||
if err := s.storage.DeleteClient(req.Id); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &apipb.DeleteClientReq{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) ListClients(ctx context.Context, req *apipb.ListClientsReq) (*apipb.ListClientsResp, error) {
|
|
||||||
clients, err := s.storage.ListClients()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp := make([]*apipb.Client, len(clients))
|
|
||||||
for i, client := range clients {
|
|
||||||
resp[i] = toPBClient(client)
|
|
||||||
}
|
|
||||||
return &apipb.ListClientsResp{Clients: resp}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) GetClient(ctx context.Context, req *apipb.GetClientReq) (*apipb.GetClientResp, error) {
|
|
||||||
if req.Id == "" {
|
|
||||||
return nil, errors.New("no client ID supplied")
|
|
||||||
}
|
|
||||||
client, err := s.storage.GetClient(req.Id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &apipb.GetClientResp{Client: toPBClient(client)}, nil
|
|
||||||
}
|
|
|
@ -1,443 +0,0 @@
|
||||||
// Code generated by protoc-gen-go.
|
|
||||||
// source: api/apipb/api.proto
|
|
||||||
// DO NOT EDIT!
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package apipb is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
api/apipb/api.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
Client
|
|
||||||
CreateClientReq
|
|
||||||
CreateClientResp
|
|
||||||
UpdateClientReq
|
|
||||||
UpdateClientResp
|
|
||||||
ListClientsReq
|
|
||||||
ListClientsResp
|
|
||||||
DeleteClientReq
|
|
||||||
DeleteClientResp
|
|
||||||
GetClientReq
|
|
||||||
GetClientResp
|
|
||||||
*/
|
|
||||||
package apipb
|
|
||||||
|
|
||||||
import proto "github.com/golang/protobuf/proto"
|
|
||||||
import fmt "fmt"
|
|
||||||
import math "math"
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "golang.org/x/net/context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
|
||||||
var _ = proto.Marshal
|
|
||||||
var _ = fmt.Errorf
|
|
||||||
var _ = math.Inf
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the proto package it is being compiled against.
|
|
||||||
// A compilation error at this line likely means your copy of the
|
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
|
||||||
Secret string `protobuf:"bytes,2,opt,name=secret" json:"secret,omitempty"`
|
|
||||||
RedirectUris []string `protobuf:"bytes,3,rep,name=redirect_uris,json=redirectUris" json:"redirect_uris,omitempty"`
|
|
||||||
TrustedPeers []string `protobuf:"bytes,4,rep,name=trusted_peers,json=trustedPeers" json:"trusted_peers,omitempty"`
|
|
||||||
Public bool `protobuf:"varint,5,opt,name=public" json:"public,omitempty"`
|
|
||||||
Name string `protobuf:"bytes,6,opt,name=name" json:"name,omitempty"`
|
|
||||||
LogoUrl string `protobuf:"bytes,7,opt,name=logo_url,json=logoUrl" json:"logo_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Client) Reset() { *m = Client{} }
|
|
||||||
func (m *Client) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*Client) ProtoMessage() {}
|
|
||||||
func (*Client) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
|
||||||
|
|
||||||
type CreateClientReq struct {
|
|
||||||
Client *Client `protobuf:"bytes,1,opt,name=client" json:"client,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *CreateClientReq) Reset() { *m = CreateClientReq{} }
|
|
||||||
func (m *CreateClientReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*CreateClientReq) ProtoMessage() {}
|
|
||||||
func (*CreateClientReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
|
||||||
|
|
||||||
func (m *CreateClientReq) GetClient() *Client {
|
|
||||||
if m != nil {
|
|
||||||
return m.Client
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateClientResp struct {
|
|
||||||
Client *Client `protobuf:"bytes,1,opt,name=client" json:"client,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *CreateClientResp) Reset() { *m = CreateClientResp{} }
|
|
||||||
func (m *CreateClientResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*CreateClientResp) ProtoMessage() {}
|
|
||||||
func (*CreateClientResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
|
||||||
|
|
||||||
func (m *CreateClientResp) GetClient() *Client {
|
|
||||||
if m != nil {
|
|
||||||
return m.Client
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateClientReq struct {
|
|
||||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
|
||||||
// Empty strings indicate that string fields should not be updated.
|
|
||||||
Secret string `protobuf:"bytes,2,opt,name=secret" json:"secret,omitempty"`
|
|
||||||
Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
|
||||||
LogoUrl string `protobuf:"bytes,4,opt,name=logo_url,json=logoUrl" json:"logo_url,omitempty"`
|
|
||||||
MakePublic bool `protobuf:"varint,5,opt,name=make_public,json=makePublic" json:"make_public,omitempty"`
|
|
||||||
MakePrivate bool `protobuf:"varint,6,opt,name=make_private,json=makePrivate" json:"make_private,omitempty"`
|
|
||||||
// If no redirect URIs are specified, the current redirect URIs are preserved.
|
|
||||||
RedirectUris []string `protobuf:"bytes,7,rep,name=redirect_uris,json=redirectUris" json:"redirect_uris,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *UpdateClientReq) Reset() { *m = UpdateClientReq{} }
|
|
||||||
func (m *UpdateClientReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*UpdateClientReq) ProtoMessage() {}
|
|
||||||
func (*UpdateClientReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
|
||||||
|
|
||||||
type UpdateClientResp struct {
|
|
||||||
Client *Client `protobuf:"bytes,1,opt,name=client" json:"client,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *UpdateClientResp) Reset() { *m = UpdateClientResp{} }
|
|
||||||
func (m *UpdateClientResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*UpdateClientResp) ProtoMessage() {}
|
|
||||||
func (*UpdateClientResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
|
||||||
|
|
||||||
func (m *UpdateClientResp) GetClient() *Client {
|
|
||||||
if m != nil {
|
|
||||||
return m.Client
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListClientsReq struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ListClientsReq) Reset() { *m = ListClientsReq{} }
|
|
||||||
func (m *ListClientsReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*ListClientsReq) ProtoMessage() {}
|
|
||||||
func (*ListClientsReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
|
||||||
|
|
||||||
type ListClientsResp struct {
|
|
||||||
Clients []*Client `protobuf:"bytes,1,rep,name=clients" json:"clients,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ListClientsResp) Reset() { *m = ListClientsResp{} }
|
|
||||||
func (m *ListClientsResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*ListClientsResp) ProtoMessage() {}
|
|
||||||
func (*ListClientsResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
|
|
||||||
|
|
||||||
func (m *ListClientsResp) GetClients() []*Client {
|
|
||||||
if m != nil {
|
|
||||||
return m.Clients
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteClientReq struct {
|
|
||||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *DeleteClientReq) Reset() { *m = DeleteClientReq{} }
|
|
||||||
func (m *DeleteClientReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*DeleteClientReq) ProtoMessage() {}
|
|
||||||
func (*DeleteClientReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
|
|
||||||
|
|
||||||
type DeleteClientResp struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *DeleteClientResp) Reset() { *m = DeleteClientResp{} }
|
|
||||||
func (m *DeleteClientResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*DeleteClientResp) ProtoMessage() {}
|
|
||||||
func (*DeleteClientResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
|
|
||||||
|
|
||||||
type GetClientReq struct {
|
|
||||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *GetClientReq) Reset() { *m = GetClientReq{} }
|
|
||||||
func (m *GetClientReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*GetClientReq) ProtoMessage() {}
|
|
||||||
func (*GetClientReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
|
|
||||||
|
|
||||||
type GetClientResp struct {
|
|
||||||
Client *Client `protobuf:"bytes,1,opt,name=client" json:"client,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *GetClientResp) Reset() { *m = GetClientResp{} }
|
|
||||||
func (m *GetClientResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*GetClientResp) ProtoMessage() {}
|
|
||||||
func (*GetClientResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
|
|
||||||
|
|
||||||
func (m *GetClientResp) GetClient() *Client {
|
|
||||||
if m != nil {
|
|
||||||
return m.Client
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
proto.RegisterType((*Client)(nil), "apipb.Client")
|
|
||||||
proto.RegisterType((*CreateClientReq)(nil), "apipb.CreateClientReq")
|
|
||||||
proto.RegisterType((*CreateClientResp)(nil), "apipb.CreateClientResp")
|
|
||||||
proto.RegisterType((*UpdateClientReq)(nil), "apipb.UpdateClientReq")
|
|
||||||
proto.RegisterType((*UpdateClientResp)(nil), "apipb.UpdateClientResp")
|
|
||||||
proto.RegisterType((*ListClientsReq)(nil), "apipb.ListClientsReq")
|
|
||||||
proto.RegisterType((*ListClientsResp)(nil), "apipb.ListClientsResp")
|
|
||||||
proto.RegisterType((*DeleteClientReq)(nil), "apipb.DeleteClientReq")
|
|
||||||
proto.RegisterType((*DeleteClientResp)(nil), "apipb.DeleteClientResp")
|
|
||||||
proto.RegisterType((*GetClientReq)(nil), "apipb.GetClientReq")
|
|
||||||
proto.RegisterType((*GetClientResp)(nil), "apipb.GetClientResp")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
|
||||||
var _ context.Context
|
|
||||||
var _ grpc.ClientConn
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
const _ = grpc.SupportPackageIsVersion3
|
|
||||||
|
|
||||||
// Client API for Storage service
|
|
||||||
|
|
||||||
type StorageClient interface {
|
|
||||||
GetClient(ctx context.Context, in *GetClientReq, opts ...grpc.CallOption) (*GetClientResp, error)
|
|
||||||
CreateClient(ctx context.Context, in *CreateClientReq, opts ...grpc.CallOption) (*CreateClientResp, error)
|
|
||||||
UpdateClient(ctx context.Context, in *UpdateClientReq, opts ...grpc.CallOption) (*UpdateClientResp, error)
|
|
||||||
DeleteClient(ctx context.Context, in *DeleteClientReq, opts ...grpc.CallOption) (*DeleteClientReq, error)
|
|
||||||
ListClients(ctx context.Context, in *ListClientsReq, opts ...grpc.CallOption) (*ListClientsResp, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type storageClient struct {
|
|
||||||
cc *grpc.ClientConn
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewStorageClient(cc *grpc.ClientConn) StorageClient {
|
|
||||||
return &storageClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *storageClient) GetClient(ctx context.Context, in *GetClientReq, opts ...grpc.CallOption) (*GetClientResp, error) {
|
|
||||||
out := new(GetClientResp)
|
|
||||||
err := grpc.Invoke(ctx, "/apipb.Storage/GetClient", in, out, c.cc, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *storageClient) CreateClient(ctx context.Context, in *CreateClientReq, opts ...grpc.CallOption) (*CreateClientResp, error) {
|
|
||||||
out := new(CreateClientResp)
|
|
||||||
err := grpc.Invoke(ctx, "/apipb.Storage/CreateClient", in, out, c.cc, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *storageClient) UpdateClient(ctx context.Context, in *UpdateClientReq, opts ...grpc.CallOption) (*UpdateClientResp, error) {
|
|
||||||
out := new(UpdateClientResp)
|
|
||||||
err := grpc.Invoke(ctx, "/apipb.Storage/UpdateClient", in, out, c.cc, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *storageClient) DeleteClient(ctx context.Context, in *DeleteClientReq, opts ...grpc.CallOption) (*DeleteClientReq, error) {
|
|
||||||
out := new(DeleteClientReq)
|
|
||||||
err := grpc.Invoke(ctx, "/apipb.Storage/DeleteClient", in, out, c.cc, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *storageClient) ListClients(ctx context.Context, in *ListClientsReq, opts ...grpc.CallOption) (*ListClientsResp, error) {
|
|
||||||
out := new(ListClientsResp)
|
|
||||||
err := grpc.Invoke(ctx, "/apipb.Storage/ListClients", in, out, c.cc, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server API for Storage service
|
|
||||||
|
|
||||||
type StorageServer interface {
|
|
||||||
GetClient(context.Context, *GetClientReq) (*GetClientResp, error)
|
|
||||||
CreateClient(context.Context, *CreateClientReq) (*CreateClientResp, error)
|
|
||||||
UpdateClient(context.Context, *UpdateClientReq) (*UpdateClientResp, error)
|
|
||||||
DeleteClient(context.Context, *DeleteClientReq) (*DeleteClientReq, error)
|
|
||||||
ListClients(context.Context, *ListClientsReq) (*ListClientsResp, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterStorageServer(s *grpc.Server, srv StorageServer) {
|
|
||||||
s.RegisterService(&_Storage_serviceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Storage_GetClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(GetClientReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(StorageServer).GetClient(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/apipb.Storage/GetClient",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(StorageServer).GetClient(ctx, req.(*GetClientReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Storage_CreateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(CreateClientReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(StorageServer).CreateClient(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/apipb.Storage/CreateClient",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(StorageServer).CreateClient(ctx, req.(*CreateClientReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Storage_UpdateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(UpdateClientReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(StorageServer).UpdateClient(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/apipb.Storage/UpdateClient",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(StorageServer).UpdateClient(ctx, req.(*UpdateClientReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Storage_DeleteClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DeleteClientReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(StorageServer).DeleteClient(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/apipb.Storage/DeleteClient",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(StorageServer).DeleteClient(ctx, req.(*DeleteClientReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Storage_ListClients_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ListClientsReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(StorageServer).ListClients(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/apipb.Storage/ListClients",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(StorageServer).ListClients(ctx, req.(*ListClientsReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _Storage_serviceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "apipb.Storage",
|
|
||||||
HandlerType: (*StorageServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "GetClient",
|
|
||||||
Handler: _Storage_GetClient_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "CreateClient",
|
|
||||||
Handler: _Storage_CreateClient_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "UpdateClient",
|
|
||||||
Handler: _Storage_UpdateClient_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "DeleteClient",
|
|
||||||
Handler: _Storage_DeleteClient_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "ListClients",
|
|
||||||
Handler: _Storage_ListClients_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: fileDescriptor0,
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { proto.RegisterFile("api/apipb/api.proto", fileDescriptor0) }
|
|
||||||
|
|
||||||
var fileDescriptor0 = []byte{
|
|
||||||
// 459 bytes of a gzipped FileDescriptorProto
|
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x8f, 0xd2, 0x40,
|
|
||||||
0x14, 0xa6, 0xc0, 0xb6, 0xf0, 0x28, 0x0b, 0x79, 0xab, 0x6b, 0xe5, 0xa0, 0xec, 0x18, 0x23, 0x27,
|
|
||||||
0x4c, 0xd6, 0xc4, 0xac, 0x1e, 0x8c, 0x66, 0x4d, 0xbc, 0x78, 0x20, 0x35, 0x9c, 0x49, 0xa1, 0x2f,
|
|
||||||
0x9b, 0x89, 0xdd, 0xed, 0x30, 0x33, 0xf8, 0xff, 0x3c, 0x7b, 0xf2, 0x1f, 0x99, 0xce, 0xb4, 0x4d,
|
|
||||||
0x07, 0x64, 0xc3, 0x85, 0xf0, 0xbe, 0xf9, 0xde, 0x7b, 0xf9, 0xbe, 0xef, 0xa5, 0x70, 0x91, 0x08,
|
|
||||||
0xfe, 0x36, 0x11, 0x5c, 0xac, 0x8b, 0xdf, 0xb9, 0x90, 0xb9, 0xce, 0xf1, 0xcc, 0x00, 0xec, 0xb7,
|
|
||||||
0x07, 0xfe, 0x6d, 0xc6, 0xe9, 0x41, 0xe3, 0x39, 0xb4, 0x79, 0x1a, 0x79, 0x53, 0x6f, 0xd6, 0x8f,
|
|
||||||
0xdb, 0x3c, 0xc5, 0x4b, 0xf0, 0x15, 0x6d, 0x24, 0xe9, 0xa8, 0x6d, 0xb0, 0xb2, 0xc2, 0x57, 0x30,
|
|
||||||
0x94, 0x94, 0x72, 0x49, 0x1b, 0xbd, 0xda, 0x49, 0xae, 0xa2, 0xce, 0xb4, 0x33, 0xeb, 0xc7, 0x61,
|
|
||||||
0x05, 0x2e, 0x25, 0x57, 0x05, 0x49, 0xcb, 0x9d, 0xd2, 0x94, 0xae, 0x04, 0x91, 0x54, 0x51, 0xd7,
|
|
||||||
0x92, 0x4a, 0x70, 0x51, 0x60, 0xc5, 0x06, 0xb1, 0x5b, 0x67, 0x7c, 0x13, 0x9d, 0x4d, 0xbd, 0x59,
|
|
||||||
0x2f, 0x2e, 0x2b, 0x44, 0xe8, 0x3e, 0x24, 0xf7, 0x14, 0xf9, 0x66, 0xaf, 0xf9, 0x8f, 0xcf, 0xa1,
|
|
||||||
0x97, 0xe5, 0x77, 0xf9, 0x6a, 0x27, 0xb3, 0x28, 0x30, 0x78, 0x50, 0xd4, 0x4b, 0x99, 0xb1, 0x1b,
|
|
||||||
0x18, 0xdd, 0x4a, 0x4a, 0x34, 0x59, 0x21, 0x31, 0x6d, 0xf1, 0x35, 0xf8, 0x1b, 0x53, 0x18, 0x3d,
|
|
||||||
0x83, 0xeb, 0xe1, 0xdc, 0xc8, 0x9d, 0x97, 0x8c, 0xf2, 0x91, 0x7d, 0x80, 0xb1, 0xdb, 0xa9, 0xc4,
|
|
||||||
0xa9, 0xad, 0x7f, 0x3d, 0x18, 0x2d, 0x45, 0xea, 0x6c, 0x3d, 0xd5, 0xc1, 0x4a, 0x5f, 0xe7, 0x88,
|
|
||||||
0xbe, 0xae, 0xa3, 0x0f, 0x5f, 0xc2, 0xe0, 0x3e, 0xf9, 0x49, 0x2b, 0xc7, 0x2b, 0x28, 0xa0, 0x85,
|
|
||||||
0xf5, 0xeb, 0x0a, 0x42, 0x4b, 0x90, 0xfc, 0x57, 0xa2, 0xad, 0x6f, 0xbd, 0xd8, 0x34, 0x2d, 0x2c,
|
|
||||||
0x74, 0x18, 0x5a, 0x70, 0x18, 0x5a, 0x61, 0x87, 0x2b, 0xe9, 0x74, 0x3b, 0xc6, 0x70, 0xfe, 0x9d,
|
|
||||||
0x2b, 0x6d, 0x51, 0x15, 0xd3, 0x96, 0x7d, 0x84, 0x91, 0x83, 0x28, 0x81, 0x6f, 0x20, 0xb0, 0x74,
|
|
||||||
0x15, 0x79, 0xd3, 0xce, 0xe1, 0xb0, 0xea, 0x95, 0x5d, 0xc1, 0xe8, 0x2b, 0x65, 0xf4, 0x88, 0xb7,
|
|
||||||
0x0c, 0x61, 0xec, 0x52, 0x94, 0x60, 0x2f, 0x20, 0xfc, 0x46, 0xfa, 0x78, 0xcf, 0x7b, 0x18, 0x36,
|
|
||||||
0xde, 0x4f, 0x16, 0x77, 0xfd, 0xa7, 0x0d, 0xc1, 0x0f, 0x9d, 0xcb, 0xe4, 0x8e, 0xf0, 0x06, 0xfa,
|
|
||||||
0xf5, 0x0c, 0xbc, 0x28, 0xf9, 0xcd, 0xad, 0x93, 0x27, 0x87, 0xa0, 0x12, 0xac, 0x85, 0x5f, 0x20,
|
|
||||||
0x6c, 0x1e, 0x1b, 0x5e, 0x56, 0xcb, 0xdc, 0xdb, 0x9d, 0x3c, 0xfb, 0x2f, 0x5e, 0x8d, 0x68, 0x06,
|
|
||||||
0x54, 0x8f, 0xd8, 0x3b, 0xc4, 0x7a, 0xc4, 0x7e, 0x9a, 0xac, 0x85, 0x9f, 0x21, 0x6c, 0xfa, 0x56,
|
|
||||||
0x8f, 0xd8, 0xf3, 0x7b, 0x72, 0x04, 0x67, 0x2d, 0xfc, 0x04, 0x83, 0x46, 0xb0, 0xf8, 0xb4, 0x24,
|
|
||||||
0xba, 0xf1, 0xd7, 0xfd, 0x7b, 0x37, 0xc0, 0x5a, 0x6b, 0xdf, 0x7c, 0x80, 0xde, 0xfd, 0x0b, 0x00,
|
|
||||||
0x00, 0xff, 0xff, 0x76, 0xa0, 0x50, 0x77, 0x97, 0x04, 0x00, 0x00,
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
// Run `make grpc` at the top level directory to regenerate Go source code.
|
|
||||||
|
|
||||||
package apipb;
|
|
||||||
|
|
||||||
message Client {
|
|
||||||
string id = 1;
|
|
||||||
string secret = 2;
|
|
||||||
|
|
||||||
repeated string redirect_uris = 3;
|
|
||||||
repeated string trusted_peers = 4;
|
|
||||||
|
|
||||||
bool public = 5;
|
|
||||||
|
|
||||||
string name = 6;
|
|
||||||
string logo_url = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateClientReq {
|
|
||||||
Client client = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateClientResp {
|
|
||||||
Client client = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateClientReq {
|
|
||||||
string id = 1;
|
|
||||||
|
|
||||||
// Empty strings indicate that string fields should not be updated.
|
|
||||||
string secret = 2;
|
|
||||||
string name = 3;
|
|
||||||
string logo_url = 4;
|
|
||||||
|
|
||||||
bool make_public = 5;
|
|
||||||
bool make_private = 6;
|
|
||||||
|
|
||||||
// If no redirect URIs are specified, the current redirect URIs are preserved.
|
|
||||||
repeated string redirect_uris = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateClientResp {
|
|
||||||
Client client = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListClientsReq {
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListClientsResp {
|
|
||||||
repeated Client clients = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteClientReq {
|
|
||||||
string id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteClientResp {}
|
|
||||||
|
|
||||||
message GetClientReq {
|
|
||||||
string id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetClientResp {
|
|
||||||
Client client = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
service Storage {
|
|
||||||
rpc CreateClient(CreateClientReq) returns (CreateClientResp) {}
|
|
||||||
rpc DeleteClient(DeleteClientReq) returns (DeleteClientReq) {}
|
|
||||||
rpc GetClient(GetClientReq) returns (GetClientResp) {}
|
|
||||||
rpc ListClients(ListClientsReq) returns (ListClientsResp) {}
|
|
||||||
rpc UpdateClient(UpdateClientReq) returns (UpdateClientResp) {}
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
// Package api implements a gRPC interface for interacting with a storage.
|
|
||||||
package api
|
|
|
@ -1,24 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
|
||||||
Use: "pokectl",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
|
||||||
fmt.Fprintln(os.Stderr, err)
|
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
}
|
|
26
glide.yaml
26
glide.yaml
|
@ -22,6 +22,11 @@ import:
|
||||||
- cipher
|
- cipher
|
||||||
- json
|
- json
|
||||||
|
|
||||||
|
- package: golang.org/x/net
|
||||||
|
version: 6a513affb38dc9788b449d59ffed099b8de18fa0
|
||||||
|
subpackages:
|
||||||
|
- context
|
||||||
|
|
||||||
- package: gopkg.in/yaml.v2
|
- package: gopkg.in/yaml.v2
|
||||||
version: a83829b6f1293c91addabc89d0571c246397bbf4
|
version: a83829b6f1293c91addabc89d0571c246397bbf4
|
||||||
|
|
||||||
|
@ -67,27 +72,6 @@ import:
|
||||||
- package: github.com/mitchellh/go-homedir
|
- package: github.com/mitchellh/go-homedir
|
||||||
verison: 756f7b183b7ab78acdbbee5c7f392838ed459dda
|
verison: 756f7b183b7ab78acdbbee5c7f392838ed459dda
|
||||||
|
|
||||||
- package: google.golang.org/grpc
|
|
||||||
version: v1.0.0
|
|
||||||
subpackages:
|
|
||||||
- codes
|
|
||||||
- credentials
|
|
||||||
- grpclog
|
|
||||||
- internal
|
|
||||||
- metadata
|
|
||||||
- naming
|
|
||||||
- transport
|
|
||||||
- peer
|
|
||||||
- package: golang.org/x/net
|
|
||||||
version: 6a513affb38dc9788b449d59ffed099b8de18fa0
|
|
||||||
subpackages:
|
|
||||||
- context # context is also imported directly by this repo.
|
|
||||||
- http2
|
|
||||||
- http2/hpack
|
|
||||||
- trace
|
|
||||||
- lex/httplex
|
|
||||||
- internal/timeseries
|
|
||||||
|
|
||||||
- package: github.com/kylelemons/godebug
|
- package: github.com/kylelemons/godebug
|
||||||
subpackages:
|
subpackages:
|
||||||
- diff
|
- diff
|
||||||
|
|
Reference in a new issue