Payments API protobuf definition (#876)

This commit is contained in:
Michal Niewrzal 2018-12-17 18:36:50 +01:00 committed by GitHub
parent a5af25c9c2
commit 1d2523cf60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 489 additions and 0 deletions

440
pkg/pb/payments.pb.go Normal file
View File

@ -0,0 +1,440 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: payments.proto
package pb
import proto "github.com/gogo/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.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// The request message containing the details needed to pay a storage node.
type PaymentRequest struct {
// ID of the storage node to be paid
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PaymentRequest) Reset() { *m = PaymentRequest{} }
func (m *PaymentRequest) String() string { return proto.CompactTextString(m) }
func (*PaymentRequest) ProtoMessage() {}
func (*PaymentRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{0}
}
func (m *PaymentRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PaymentRequest.Unmarshal(m, b)
}
func (m *PaymentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PaymentRequest.Marshal(b, m, deterministic)
}
func (dst *PaymentRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_PaymentRequest.Merge(dst, src)
}
func (m *PaymentRequest) XXX_Size() int {
return xxx_messageInfo_PaymentRequest.Size(m)
}
func (m *PaymentRequest) XXX_DiscardUnknown() {
xxx_messageInfo_PaymentRequest.DiscardUnknown(m)
}
var xxx_messageInfo_PaymentRequest proto.InternalMessageInfo
func (m *PaymentRequest) GetNodeId() string {
if m != nil {
return m.NodeId
}
return ""
}
// The response message for payments.
type PaymentResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PaymentResponse) Reset() { *m = PaymentResponse{} }
func (m *PaymentResponse) String() string { return proto.CompactTextString(m) }
func (*PaymentResponse) ProtoMessage() {}
func (*PaymentResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{1}
}
func (m *PaymentResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PaymentResponse.Unmarshal(m, b)
}
func (m *PaymentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PaymentResponse.Marshal(b, m, deterministic)
}
func (dst *PaymentResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_PaymentResponse.Merge(dst, src)
}
func (m *PaymentResponse) XXX_Size() int {
return xxx_messageInfo_PaymentResponse.Size(m)
}
func (m *PaymentResponse) XXX_DiscardUnknown() {
xxx_messageInfo_PaymentResponse.DiscardUnknown(m)
}
var xxx_messageInfo_PaymentResponse proto.InternalMessageInfo
// The request message containing the details needed to calculate outstanding balance for a storage node.
type CalculateRequest struct {
// ID of the storage node to be calculated
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CalculateRequest) Reset() { *m = CalculateRequest{} }
func (m *CalculateRequest) String() string { return proto.CompactTextString(m) }
func (*CalculateRequest) ProtoMessage() {}
func (*CalculateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{2}
}
func (m *CalculateRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CalculateRequest.Unmarshal(m, b)
}
func (m *CalculateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CalculateRequest.Marshal(b, m, deterministic)
}
func (dst *CalculateRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CalculateRequest.Merge(dst, src)
}
func (m *CalculateRequest) XXX_Size() int {
return xxx_messageInfo_CalculateRequest.Size(m)
}
func (m *CalculateRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CalculateRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CalculateRequest proto.InternalMessageInfo
func (m *CalculateRequest) GetNodeId() string {
if m != nil {
return m.NodeId
}
return ""
}
// The response message for payment calculations.
type CalculateResponse struct {
// ID of the storage node calculation made for
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
// total balance in Storj of outstanding credit
Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CalculateResponse) Reset() { *m = CalculateResponse{} }
func (m *CalculateResponse) String() string { return proto.CompactTextString(m) }
func (*CalculateResponse) ProtoMessage() {}
func (*CalculateResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{3}
}
func (m *CalculateResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CalculateResponse.Unmarshal(m, b)
}
func (m *CalculateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CalculateResponse.Marshal(b, m, deterministic)
}
func (dst *CalculateResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CalculateResponse.Merge(dst, src)
}
func (m *CalculateResponse) XXX_Size() int {
return xxx_messageInfo_CalculateResponse.Size(m)
}
func (m *CalculateResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CalculateResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CalculateResponse proto.InternalMessageInfo
func (m *CalculateResponse) GetNodeId() string {
if m != nil {
return m.NodeId
}
return ""
}
func (m *CalculateResponse) GetTotal() int64 {
if m != nil {
return m.Total
}
return 0
}
// The request message for adjusting the cost of storage/bandwidth for a satelitte.
type AdjustPricesRequest struct {
// price per gigabyte of bandwidth calculated in Storj
Bandwidth int64 `protobuf:"varint,1,opt,name=bandwidth,proto3" json:"bandwidth,omitempty"`
// price for GB/H of storage calculated in Storj
Storage int64 `protobuf:"varint,2,opt,name=storage,proto3" json:"storage,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AdjustPricesRequest) Reset() { *m = AdjustPricesRequest{} }
func (m *AdjustPricesRequest) String() string { return proto.CompactTextString(m) }
func (*AdjustPricesRequest) ProtoMessage() {}
func (*AdjustPricesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{4}
}
func (m *AdjustPricesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AdjustPricesRequest.Unmarshal(m, b)
}
func (m *AdjustPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AdjustPricesRequest.Marshal(b, m, deterministic)
}
func (dst *AdjustPricesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_AdjustPricesRequest.Merge(dst, src)
}
func (m *AdjustPricesRequest) XXX_Size() int {
return xxx_messageInfo_AdjustPricesRequest.Size(m)
}
func (m *AdjustPricesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_AdjustPricesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_AdjustPricesRequest proto.InternalMessageInfo
func (m *AdjustPricesRequest) GetBandwidth() int64 {
if m != nil {
return m.Bandwidth
}
return 0
}
func (m *AdjustPricesRequest) GetStorage() int64 {
if m != nil {
return m.Storage
}
return 0
}
// The response message from adjusting cost basis on satelittes.
type AdjustPricesResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AdjustPricesResponse) Reset() { *m = AdjustPricesResponse{} }
func (m *AdjustPricesResponse) String() string { return proto.CompactTextString(m) }
func (*AdjustPricesResponse) ProtoMessage() {}
func (*AdjustPricesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_payments_74d7a55fc29ae2d5, []int{5}
}
func (m *AdjustPricesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AdjustPricesResponse.Unmarshal(m, b)
}
func (m *AdjustPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AdjustPricesResponse.Marshal(b, m, deterministic)
}
func (dst *AdjustPricesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_AdjustPricesResponse.Merge(dst, src)
}
func (m *AdjustPricesResponse) XXX_Size() int {
return xxx_messageInfo_AdjustPricesResponse.Size(m)
}
func (m *AdjustPricesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_AdjustPricesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_AdjustPricesResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*PaymentRequest)(nil), "PaymentRequest")
proto.RegisterType((*PaymentResponse)(nil), "PaymentResponse")
proto.RegisterType((*CalculateRequest)(nil), "CalculateRequest")
proto.RegisterType((*CalculateResponse)(nil), "CalculateResponse")
proto.RegisterType((*AdjustPricesRequest)(nil), "AdjustPricesRequest")
proto.RegisterType((*AdjustPricesResponse)(nil), "AdjustPricesResponse")
}
// 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
// PaymentsClient is the client API for Payments service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type PaymentsClient interface {
// Pay creates a payment to a single storage node
Pay(ctx context.Context, in *PaymentRequest, opts ...grpc.CallOption) (*PaymentResponse, error)
// Calculate determines the outstanding balance for a given storage node
Calculate(ctx context.Context, in *CalculateRequest, opts ...grpc.CallOption) (*CalculateResponse, error)
// AdjustPrices sets the prices paid by a satellite for data at rest and bandwidth
AdjustPrices(ctx context.Context, in *AdjustPricesRequest, opts ...grpc.CallOption) (*AdjustPricesResponse, error)
}
type paymentsClient struct {
cc *grpc.ClientConn
}
func NewPaymentsClient(cc *grpc.ClientConn) PaymentsClient {
return &paymentsClient{cc}
}
func (c *paymentsClient) Pay(ctx context.Context, in *PaymentRequest, opts ...grpc.CallOption) (*PaymentResponse, error) {
out := new(PaymentResponse)
err := c.cc.Invoke(ctx, "/Payments/Pay", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *paymentsClient) Calculate(ctx context.Context, in *CalculateRequest, opts ...grpc.CallOption) (*CalculateResponse, error) {
out := new(CalculateResponse)
err := c.cc.Invoke(ctx, "/Payments/Calculate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *paymentsClient) AdjustPrices(ctx context.Context, in *AdjustPricesRequest, opts ...grpc.CallOption) (*AdjustPricesResponse, error) {
out := new(AdjustPricesResponse)
err := c.cc.Invoke(ctx, "/Payments/AdjustPrices", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// PaymentsServer is the server API for Payments service.
type PaymentsServer interface {
// Pay creates a payment to a single storage node
Pay(context.Context, *PaymentRequest) (*PaymentResponse, error)
// Calculate determines the outstanding balance for a given storage node
Calculate(context.Context, *CalculateRequest) (*CalculateResponse, error)
// AdjustPrices sets the prices paid by a satellite for data at rest and bandwidth
AdjustPrices(context.Context, *AdjustPricesRequest) (*AdjustPricesResponse, error)
}
func RegisterPaymentsServer(s *grpc.Server, srv PaymentsServer) {
s.RegisterService(&_Payments_serviceDesc, srv)
}
func _Payments_Pay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PaymentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PaymentsServer).Pay(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Payments/Pay",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PaymentsServer).Pay(ctx, req.(*PaymentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Payments_Calculate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CalculateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PaymentsServer).Calculate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Payments/Calculate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PaymentsServer).Calculate(ctx, req.(*CalculateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Payments_AdjustPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AdjustPricesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PaymentsServer).AdjustPrices(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Payments/AdjustPrices",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PaymentsServer).AdjustPrices(ctx, req.(*AdjustPricesRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Payments_serviceDesc = grpc.ServiceDesc{
ServiceName: "Payments",
HandlerType: (*PaymentsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Pay",
Handler: _Payments_Pay_Handler,
},
{
MethodName: "Calculate",
Handler: _Payments_Calculate_Handler,
},
{
MethodName: "AdjustPrices",
Handler: _Payments_AdjustPrices_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "payments.proto",
}
func init() { proto.RegisterFile("payments.proto", fileDescriptor_payments_74d7a55fc29ae2d5) }
var fileDescriptor_payments_74d7a55fc29ae2d5 = []byte{
// 261 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x51, 0xc1, 0x4a, 0xc3, 0x40,
0x14, 0x24, 0x8d, 0xb6, 0xe6, 0x21, 0x6d, 0xf3, 0x8c, 0x1a, 0x82, 0x87, 0xb2, 0xa7, 0x88, 0xb0,
0x87, 0x7a, 0xf4, 0x64, 0x3d, 0x79, 0x10, 0x42, 0x8e, 0x5e, 0x64, 0xd3, 0x5d, 0x34, 0x12, 0xb3,
0x31, 0xef, 0x05, 0xe9, 0x07, 0xf9, 0x9f, 0x62, 0xd3, 0xd6, 0xb6, 0x46, 0x3c, 0xce, 0x30, 0x3b,
0x3b, 0x33, 0x0f, 0x86, 0x95, 0x5a, 0xbc, 0x99, 0x92, 0x49, 0x56, 0xb5, 0x65, 0x2b, 0x2e, 0x61,
0x98, 0xb4, 0x4c, 0x6a, 0xde, 0x1b, 0x43, 0x8c, 0xe7, 0x30, 0x28, 0xad, 0x36, 0x4f, 0xb9, 0x0e,
0x9d, 0x89, 0x13, 0x7b, 0x69, 0xff, 0x1b, 0xde, 0x6b, 0xe1, 0xc3, 0x68, 0x23, 0xa5, 0xca, 0x96,
0x64, 0xc4, 0x15, 0x8c, 0xef, 0x54, 0x31, 0x6f, 0x0a, 0xc5, 0xe6, 0xdf, 0xf7, 0x33, 0xf0, 0xb7,
0xc4, 0xad, 0xc3, 0x9f, 0x6a, 0x0c, 0xe0, 0x90, 0x2d, 0xab, 0x22, 0xec, 0x4d, 0x9c, 0xd8, 0x4d,
0x5b, 0x20, 0x1e, 0xe0, 0xe4, 0x56, 0xbf, 0x36, 0xc4, 0x49, 0x9d, 0xcf, 0x0d, 0xad, 0xff, 0xbc,
0x00, 0x2f, 0x53, 0xa5, 0xfe, 0xc8, 0x35, 0xbf, 0x2c, 0x7d, 0xdc, 0xf4, 0x87, 0xc0, 0x10, 0x06,
0xc4, 0xb6, 0x56, 0xcf, 0x66, 0x65, 0xb6, 0x86, 0xe2, 0x0c, 0x82, 0x5d, 0xbb, 0x36, 0xd5, 0xf4,
0xd3, 0x81, 0xa3, 0x55, 0x57, 0xc2, 0x18, 0xdc, 0x44, 0x2d, 0x70, 0x24, 0x77, 0x87, 0x8a, 0xc6,
0x72, 0x6f, 0x0e, 0x9c, 0x82, 0xb7, 0x69, 0x88, 0xbe, 0xdc, 0x9f, 0x26, 0x42, 0xf9, 0x7b, 0x80,
0x1b, 0x38, 0xde, 0x8e, 0x80, 0x81, 0xec, 0x28, 0x18, 0x9d, 0xca, 0xae, 0x9c, 0xb3, 0x83, 0xc7,
0x5e, 0x95, 0x65, 0xfd, 0xe5, 0x29, 0xaf, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x13, 0xda, 0x72,
0x07, 0xdc, 0x01, 0x00, 0x00,
}

49
pkg/pb/payments.proto Normal file
View File

@ -0,0 +1,49 @@
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
syntax = "proto3";
option go_package = "pb";
// The service definition for the Payments API
service Payments {
// Pay creates a payment to a single storage node
rpc Pay(PaymentRequest) returns (PaymentResponse);
// Calculate determines the outstanding balance for a given storage node
rpc Calculate(CalculateRequest) returns (CalculateResponse);
// AdjustPrices sets the prices paid by a satellite for data at rest and bandwidth
rpc AdjustPrices(AdjustPricesRequest) returns (AdjustPricesResponse);
}
// The request message containing the details needed to pay a storage node.
message PaymentRequest {
// ID of the storage node to be paid
string node_id = 1;
}
// The response message for payments.
message PaymentResponse {}
// The request message containing the details needed to calculate outstanding balance for a storage node.
message CalculateRequest {
// ID of the storage node to be calculated
string node_id = 1;
}
// The response message for payment calculations.
message CalculateResponse {
// ID of the storage node calculation made for
string node_id = 1;
// total balance in Storj of outstanding credit
int64 total = 2;
}
// The request message for adjusting the cost of storage/bandwidth for a satelitte.
message AdjustPricesRequest {
// price per gigabyte of bandwidth calculated in Storj
int64 bandwidth = 1;
// price for GB/H of storage calculated in Storj
int64 storage = 2;
}
// The response message from adjusting cost basis on satelittes.
message AdjustPricesResponse {}