Commit d1151cae authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Add new console protocol

parent 17e40ae7
Loading
Loading
Loading
Loading

console/console.pb.go

0 → 100644
+326 −0
Original line number Diff line number Diff line
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: console/console.proto

/*
Package console is a generated protocol buffer package.

It is generated from these files:
	console/console.proto

It has these top-level messages:
	AccountExport
	AccountId
	Authenticate
	Session
*/
package console

import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import nakama_api "github.com/heroiclabs/nakama/api"
import _ "google.golang.org/genproto/googleapis/api/annotations"
import google_protobuf1 "github.com/golang/protobuf/ptypes/empty"
import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"

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

// *
// An export of all information stored for a user account.
type AccountExport struct {
	// The user's account details.
	Account *nakama_api.Account `protobuf:"bytes,1,opt,name=account" json:"account,omitempty"`
	// The user's groups.
	Groups []*nakama_api.Group `protobuf:"bytes,2,rep,name=groups" json:"groups,omitempty"`
}

func (m *AccountExport) Reset()                    { *m = AccountExport{} }
func (m *AccountExport) String() string            { return proto.CompactTextString(m) }
func (*AccountExport) ProtoMessage()               {}
func (*AccountExport) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }

func (m *AccountExport) GetAccount() *nakama_api.Account {
	if m != nil {
		return m.Account
	}
	return nil
}

func (m *AccountExport) GetGroups() []*nakama_api.Group {
	if m != nil {
		return m.Groups
	}
	return nil
}

// *
// The identifier for a user account.
type AccountId struct {
	// The unique identifier of the user account.
	Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
}

func (m *AccountId) Reset()                    { *m = AccountId{} }
func (m *AccountId) String() string            { return proto.CompactTextString(m) }
func (*AccountId) ProtoMessage()               {}
func (*AccountId) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }

func (m *AccountId) GetId() string {
	if m != nil {
		return m.Id
	}
	return ""
}

// *
// Authenticate against the server with username+password.
type Authenticate struct {
	// The username of the user.
	Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"`
	// The password of the user.
	Password string `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"`
}

func (m *Authenticate) Reset()                    { *m = Authenticate{} }
func (m *Authenticate) String() string            { return proto.CompactTextString(m) }
func (*Authenticate) ProtoMessage()               {}
func (*Authenticate) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }

func (m *Authenticate) GetUsername() string {
	if m != nil {
		return m.Username
	}
	return ""
}

func (m *Authenticate) GetPassword() string {
	if m != nil {
		return m.Password
	}
	return ""
}

// *
// A user's session used to authenticate messages.
type Session struct {
	// Authentication credentials.
	Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"`
}

func (m *Session) Reset()                    { *m = Session{} }
func (m *Session) String() string            { return proto.CompactTextString(m) }
func (*Session) ProtoMessage()               {}
func (*Session) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }

func (m *Session) GetToken() string {
	if m != nil {
		return m.Token
	}
	return ""
}

func init() {
	proto.RegisterType((*AccountExport)(nil), "nakama.console.AccountExport")
	proto.RegisterType((*AccountId)(nil), "nakama.console.AccountId")
	proto.RegisterType((*Authenticate)(nil), "nakama.console.Authenticate")
	proto.RegisterType((*Session)(nil), "nakama.console.Session")
}

// 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.SupportPackageIsVersion4

// Client API for Console service

type ConsoleClient interface {
	// Authenticate a user with username+password.
	Login(ctx context.Context, in *Authenticate, opts ...grpc.CallOption) (*Session, error)
	// Delete all information stored for a user account.
	AccountDelete(ctx context.Context, in *AccountId, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
	// Export all information stored about a user account.
	AccountExportFunc(ctx context.Context, in *AccountId, opts ...grpc.CallOption) (*AccountExport, error)
}

type consoleClient struct {
	cc *grpc.ClientConn
}

func NewConsoleClient(cc *grpc.ClientConn) ConsoleClient {
	return &consoleClient{cc}
}

func (c *consoleClient) Login(ctx context.Context, in *Authenticate, opts ...grpc.CallOption) (*Session, error) {
	out := new(Session)
	err := grpc.Invoke(ctx, "/nakama.console.Console/Login", in, out, c.cc, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *consoleClient) AccountDelete(ctx context.Context, in *AccountId, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) {
	out := new(google_protobuf1.Empty)
	err := grpc.Invoke(ctx, "/nakama.console.Console/AccountDelete", in, out, c.cc, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *consoleClient) AccountExportFunc(ctx context.Context, in *AccountId, opts ...grpc.CallOption) (*AccountExport, error) {
	out := new(AccountExport)
	err := grpc.Invoke(ctx, "/nakama.console.Console/AccountExportFunc", in, out, c.cc, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// Server API for Console service

type ConsoleServer interface {
	// Authenticate a user with username+password.
	Login(context.Context, *Authenticate) (*Session, error)
	// Delete all information stored for a user account.
	AccountDelete(context.Context, *AccountId) (*google_protobuf1.Empty, error)
	// Export all information stored about a user account.
	AccountExportFunc(context.Context, *AccountId) (*AccountExport, error)
}

func RegisterConsoleServer(s *grpc.Server, srv ConsoleServer) {
	s.RegisterService(&_Console_serviceDesc, srv)
}

func _Console_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(Authenticate)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(ConsoleServer).Login(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/nakama.console.Console/Login",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(ConsoleServer).Login(ctx, req.(*Authenticate))
	}
	return interceptor(ctx, in, info, handler)
}

func _Console_AccountDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(AccountId)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(ConsoleServer).AccountDelete(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/nakama.console.Console/AccountDelete",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(ConsoleServer).AccountDelete(ctx, req.(*AccountId))
	}
	return interceptor(ctx, in, info, handler)
}

func _Console_AccountExportFunc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(AccountId)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(ConsoleServer).AccountExportFunc(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/nakama.console.Console/AccountExportFunc",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(ConsoleServer).AccountExportFunc(ctx, req.(*AccountId))
	}
	return interceptor(ctx, in, info, handler)
}

var _Console_serviceDesc = grpc.ServiceDesc{
	ServiceName: "nakama.console.Console",
	HandlerType: (*ConsoleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Login",
			Handler:    _Console_Login_Handler,
		},
		{
			MethodName: "AccountDelete",
			Handler:    _Console_AccountDelete_Handler,
		},
		{
			MethodName: "AccountExportFunc",
			Handler:    _Console_AccountExportFunc_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "console/console.proto",
}

func init() { proto.RegisterFile("console/console.proto", fileDescriptor0) }

var fileDescriptor0 = []byte{
	// 546 bytes of a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x00,
}
+240 −0
Original line number Diff line number Diff line
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: console/console.proto

/*
Package console is a reverse proxy.

It translates gRPC into RESTful JSON APIs.
*/
package console

import (
	"io"
	"net/http"

	"github.com/golang/protobuf/proto"
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
	"github.com/grpc-ecosystem/grpc-gateway/utilities"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/grpclog"
	"google.golang.org/grpc/status"
)

var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray

func request_Console_Login_0(ctx context.Context, marshaler runtime.Marshaler, client ConsoleClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
	var protoReq Authenticate
	var metadata runtime.ServerMetadata

	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
	}

	msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
	return msg, metadata, err

}

func request_Console_AccountDelete_0(ctx context.Context, marshaler runtime.Marshaler, client ConsoleClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
	var protoReq AccountId
	var metadata runtime.ServerMetadata

	var (
		val string
		ok  bool
		err error
		_   = err
	)

	val, ok = pathParams["id"]
	if !ok {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
	}

	protoReq.Id, err = runtime.String(val)

	if err != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
	}

	msg, err := client.AccountDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
	return msg, metadata, err

}

func request_Console_AccountExportFunc_0(ctx context.Context, marshaler runtime.Marshaler, client ConsoleClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
	var protoReq AccountId
	var metadata runtime.ServerMetadata

	var (
		val string
		ok  bool
		err error
		_   = err
	)

	val, ok = pathParams["id"]
	if !ok {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
	}

	protoReq.Id, err = runtime.String(val)

	if err != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
	}

	msg, err := client.AccountExportFunc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
	return msg, metadata, err

}

// RegisterConsoleHandlerFromEndpoint is same as RegisterConsoleHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterConsoleHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
	conn, err := grpc.Dial(endpoint, opts...)
	if err != nil {
		return err
	}
	defer func() {
		if err != nil {
			if cerr := conn.Close(); cerr != nil {
				grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
			}
			return
		}
		go func() {
			<-ctx.Done()
			if cerr := conn.Close(); cerr != nil {
				grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
			}
		}()
	}()

	return RegisterConsoleHandler(ctx, mux, conn)
}

// RegisterConsoleHandler registers the http handlers for service Console to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterConsoleHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
	return RegisterConsoleHandlerClient(ctx, mux, NewConsoleClient(conn))
}

// RegisterConsoleHandler registers the http handlers for service Console to "mux".
// The handlers forward requests to the grpc endpoint over the given implementation of "ConsoleClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ConsoleClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "ConsoleClient" to call the correct interceptors.
func RegisterConsoleHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ConsoleClient) error {

	mux.Handle("POST", pattern_Console_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
		ctx, cancel := context.WithCancel(req.Context())
		defer cancel()
		if cn, ok := w.(http.CloseNotifier); ok {
			go func(done <-chan struct{}, closed <-chan bool) {
				select {
				case <-done:
				case <-closed:
					cancel()
				}
			}(ctx.Done(), cn.CloseNotify())
		}
		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
		rctx, err := runtime.AnnotateContext(ctx, mux, req)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}
		resp, md, err := request_Console_Login_0(rctx, inboundMarshaler, client, req, pathParams)
		ctx = runtime.NewServerMetadataContext(ctx, md)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}

		forward_Console_Login_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)

	})

	mux.Handle("DELETE", pattern_Console_AccountDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
		ctx, cancel := context.WithCancel(req.Context())
		defer cancel()
		if cn, ok := w.(http.CloseNotifier); ok {
			go func(done <-chan struct{}, closed <-chan bool) {
				select {
				case <-done:
				case <-closed:
					cancel()
				}
			}(ctx.Done(), cn.CloseNotify())
		}
		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
		rctx, err := runtime.AnnotateContext(ctx, mux, req)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}
		resp, md, err := request_Console_AccountDelete_0(rctx, inboundMarshaler, client, req, pathParams)
		ctx = runtime.NewServerMetadataContext(ctx, md)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}

		forward_Console_AccountDelete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)

	})

	mux.Handle("GET", pattern_Console_AccountExportFunc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
		ctx, cancel := context.WithCancel(req.Context())
		defer cancel()
		if cn, ok := w.(http.CloseNotifier); ok {
			go func(done <-chan struct{}, closed <-chan bool) {
				select {
				case <-done:
				case <-closed:
					cancel()
				}
			}(ctx.Done(), cn.CloseNotify())
		}
		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
		rctx, err := runtime.AnnotateContext(ctx, mux, req)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}
		resp, md, err := request_Console_AccountExportFunc_0(rctx, inboundMarshaler, client, req, pathParams)
		ctx = runtime.NewServerMetadataContext(ctx, md)
		if err != nil {
			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
			return
		}

		forward_Console_AccountExportFunc_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)

	})

	return nil
}

var (
	pattern_Console_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "account", "authenticate"}, ""))

	pattern_Console_AccountDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v2", "account", "id"}, ""))

	pattern_Console_AccountExportFunc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"v2", "account", "id", "export"}, ""))
)

var (
	forward_Console_Login_0 = runtime.ForwardResponseMessage

	forward_Console_AccountDelete_0 = runtime.ForwardResponseMessage

	forward_Console_AccountExportFunc_0 = runtime.ForwardResponseMessage
)

console/console.proto

0 → 100644
+105 −0
Original line number Diff line number Diff line
// Copyright 2018 The Nakama Authors
//
// 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.

/**
 * The RPC protocol for the developer console.
 */
syntax = "proto3";

package nakama.console;

import "github.com/heroiclabs/nakama/api/api.proto";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";

option go_package = "console";

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
  info: {
    title: "Nakama console API v2";
    version: "2.0";
    contact: {
      name: "The Nakama Authors & Contributors";
      url: "https://github.com/heroiclabs/nakama";
      email: "hello@heroiclabs.com";
    };
  };
  external_docs: {
    url: "https://heroiclabs.com/docs";
    description: "Nakama server console documentation";
  }
  schemes: HTTP;
  consumes: "application/json";
  produces: "application/json";
};

/**
 * The developer console RPC protocol service built with GRPC.
 */
service Console {
  // Authenticate a user with username+password.
  rpc Login (Authenticate) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate",
      body: "*"
    };
  }

  // Delete all information stored for a user account.
  rpc AccountDelete (AccountId) returns (google.protobuf.Empty) {
    option (google.api.http).delete = "/v2/account/{id}";
  }

  // Export all information stored about a user account.
  rpc AccountExportFunc (AccountId) returns (AccountExport) {
    option (google.api.http).get = "/v2/account/{id}/export";
  }
}

/**
 * An export of all information stored for a user account.
 */
message AccountExport {
  // The user's account details.
  nakama.api.Account account = 1;
  // The user's groups.
  repeated nakama.api.Group groups = 2;
}

/**
 * The identifier for a user account.
 */
message AccountId {
  // The unique identifier of the user account.
  string id = 1;
}

/**
 * Authenticate against the server with username+password.
 */
message Authenticate {
  // The username of the user.
  string username = 1;
  // The password of the user.
  string password = 2;
}

/**
 * A user's session used to authenticate messages.
 */
message Session {
  // Authentication credentials.
  string token = 1;
}
+320 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −0

Empty file added.