added query

ignite scaffold query der zigbeeID --module der -r der:DER

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2025-05-21 00:00:23 +02:00
parent 86afb74aaa
commit 4e11191938
No known key found for this signature in database
8 changed files with 674 additions and 24 deletions

View File

@ -47663,6 +47663,54 @@ paths:
type: boolean type: boolean
tags: tags:
- Query - Query
/planetmint/der/der/{zigbeeID}:
get:
summary: Queries a list of Der items.
operationId: PlanetmintgoDerDer
responses:
'200':
description: A successful response.
schema:
type: object
properties:
der:
type: object
properties:
zigbeeID:
type: string
dirigeraID:
type: string
dirigeraMAC:
type: string
plmntAddress:
type: string
liquidAddress:
type: string
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: zigbeeID
in: path
required: true
type: string
tags:
- Query
/planetmint/der/params: /planetmint/der/params:
get: get:
summary: Parameters queries the parameters of the module. summary: Parameters queries the parameters of the module.
@ -77461,6 +77509,22 @@ definitions:
planetmintgo.der.Params: planetmintgo.der.Params:
type: object type: object
description: Params defines the parameters for the module. description: Params defines the parameters for the module.
planetmintgo.der.QueryDerResponse:
type: object
properties:
der:
type: object
properties:
zigbeeID:
type: string
dirigeraID:
type: string
dirigeraMAC:
type: string
plmntAddress:
type: string
liquidAddress:
type: string
planetmintgo.der.QueryParamsResponse: planetmintgo.der.QueryParamsResponse:
type: object type: object
properties: properties:

View File

@ -1,26 +1,45 @@
syntax = "proto3"; syntax = "proto3";
package planetmintgo.der; package planetmintgo.der;
import "gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/base/query/v1beta1/pagination.proto";
import "planetmintgo/der/params.proto"; import "planetmintgo/der/params.proto";
import "planetmintgo/der/der.proto";
option go_package = "github.com/planetmint/planetmint-go/x/der/types"; option go_package = "github.com/planetmint/planetmint-go/x/der/types";
// Query defines the gRPC querier service. // Query defines the gRPC querier service.
service Query { service Query {
// Parameters queries the parameters of the module. // Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/planetmint/der/params"; option (google.api.http).get = "/planetmint/der/params";
}
// Queries a list of Der items.
rpc Der (QueryDerRequest) returns (QueryDerResponse) {
option (google.api.http).get = "/planetmint/der/der/{zigbeeID}";
} }
} }
// QueryParamsRequest is request type for the Query/Params RPC method. // QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {} message QueryParamsRequest {}
// QueryParamsResponse is response type for the Query/Params RPC method. // QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse { message QueryParamsResponse {
// params holds all the parameters of this module. // params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false]; Params params = 1 [(gogoproto.nullable) = false];
} }
message QueryDerRequest {
string zigbeeID = 1;
}
message QueryDerResponse {
DER der = 1;
}

View File

@ -25,6 +25,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
} }
cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdDer())
// this line is used by starport scaffolding # 1 // this line is used by starport scaffolding # 1
return cmd return cmd

View File

@ -0,0 +1,46 @@
package cli
import (
"strconv"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/planetmint/planetmint-go/x/der/types"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdDer() *cobra.Command {
cmd := &cobra.Command{
Use: "der [zigbee-id]",
Short: "Query der",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqZigbeeID := args[0]
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryDerRequest{
ZigbeeID: reqZigbeeID,
}
res, err := queryClient.Der(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

View File

@ -14,7 +14,7 @@ func (k Keeper) StoreDerAttest(ctx sdk.Context, asset types.DER) {
store.Set(util.SerializeString(asset.ZigbeeID), appendValue) store.Set(util.SerializeString(asset.ZigbeeID), appendValue)
} }
func (k Keeper) LookupLiquidAsset(ctx sdk.Context, zigbeeID string) (val types.DER, found bool) { func (k Keeper) LookupDerAsset(ctx sdk.Context, zigbeeID string) (val types.DER, found bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DerAssetKey)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DerAssetKey))
derAsset := store.Get(util.SerializeString(zigbeeID)) derAsset := store.Get(util.SerializeString(zigbeeID))

25
x/der/keeper/query_der.go Normal file
View File

@ -0,0 +1,25 @@
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/der/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k Keeper) Der(goCtx context.Context, req *types.QueryDerRequest) (*types.QueryDerResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
der, found := k.LookupDerAsset(ctx, req.ZigbeeID)
if !found {
return nil, status.Error(codes.NotFound, "error zigbeeID not found: "+req.ZigbeeID)
}
return &types.QueryDerResponse{Der: &der}, nil
}

View File

@ -113,34 +113,130 @@ func (m *QueryParamsResponse) GetParams() Params {
return Params{} return Params{}
} }
type QueryDerRequest struct {
ZigbeeID string `protobuf:"bytes,1,opt,name=zigbeeID,proto3" json:"zigbeeID,omitempty"`
}
func (m *QueryDerRequest) Reset() { *m = QueryDerRequest{} }
func (m *QueryDerRequest) String() string { return proto.CompactTextString(m) }
func (*QueryDerRequest) ProtoMessage() {}
func (*QueryDerRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_44ad24dfc974d8be, []int{2}
}
func (m *QueryDerRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryDerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryDerRequest.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *QueryDerRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryDerRequest.Merge(m, src)
}
func (m *QueryDerRequest) XXX_Size() int {
return m.Size()
}
func (m *QueryDerRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QueryDerRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QueryDerRequest proto.InternalMessageInfo
func (m *QueryDerRequest) GetZigbeeID() string {
if m != nil {
return m.ZigbeeID
}
return ""
}
type QueryDerResponse struct {
Der *DER `protobuf:"bytes,1,opt,name=der,proto3" json:"der,omitempty"`
}
func (m *QueryDerResponse) Reset() { *m = QueryDerResponse{} }
func (m *QueryDerResponse) String() string { return proto.CompactTextString(m) }
func (*QueryDerResponse) ProtoMessage() {}
func (*QueryDerResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_44ad24dfc974d8be, []int{3}
}
func (m *QueryDerResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryDerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryDerResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *QueryDerResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryDerResponse.Merge(m, src)
}
func (m *QueryDerResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryDerResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryDerResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryDerResponse proto.InternalMessageInfo
func (m *QueryDerResponse) GetDer() *DER {
if m != nil {
return m.Der
}
return nil
}
func init() { func init() {
proto.RegisterType((*QueryParamsRequest)(nil), "planetmintgo.der.QueryParamsRequest") proto.RegisterType((*QueryParamsRequest)(nil), "planetmintgo.der.QueryParamsRequest")
proto.RegisterType((*QueryParamsResponse)(nil), "planetmintgo.der.QueryParamsResponse") proto.RegisterType((*QueryParamsResponse)(nil), "planetmintgo.der.QueryParamsResponse")
proto.RegisterType((*QueryDerRequest)(nil), "planetmintgo.der.QueryDerRequest")
proto.RegisterType((*QueryDerResponse)(nil), "planetmintgo.der.QueryDerResponse")
} }
func init() { proto.RegisterFile("planetmintgo/der/query.proto", fileDescriptor_44ad24dfc974d8be) } func init() { proto.RegisterFile("planetmintgo/der/query.proto", fileDescriptor_44ad24dfc974d8be) }
var fileDescriptor_44ad24dfc974d8be = []byte{ var fileDescriptor_44ad24dfc974d8be = []byte{
// 301 bytes of a gzipped FileDescriptorProto // 398 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xc1, 0x4a, 0xc3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4f, 0x8b, 0xd3, 0x40,
0x10, 0x86, 0x13, 0xd1, 0x1c, 0xd6, 0x8b, 0xac, 0x45, 0x42, 0xa8, 0xab, 0x04, 0x05, 0x11, 0xcc, 0x18, 0x87, 0x13, 0xab, 0x45, 0xc7, 0x83, 0x65, 0xac, 0x52, 0x42, 0x1d, 0x6b, 0xf0, 0x1f, 0x42,
0xd2, 0x0a, 0x3e, 0x40, 0x6f, 0x1e, 0x04, 0xed, 0xd1, 0xdb, 0xa6, 0x5d, 0xd6, 0x40, 0xb3, 0xb3, 0x33, 0xb4, 0x82, 0x17, 0x6f, 0x25, 0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x86, 0xd8, 0xeb, 0x0d, 0xb1, 0x4f, 0x37, 0xc4, 0xfe, 0xb7, 0x25, 0xd6, 0x7a,
0x4b, 0xac, 0xe3, 0x2d, 0xb1, 0xbe, 0x51, 0x1e, 0xeb, 0xef, 0x79, 0xe8, 0xcd, 0x44, 0xb2, 0xef,
0xa8, 0x8f, 0x43, 0x2e, 0xe8, 0x4f, 0xe3, 0xd3, 0xcb, 0x0c, 0x54, 0xd8, 0x36, 0x7f, 0xc6, 0xfb,
0x8b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x59, 0x83, 0x68, 0xe6, 0x02, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -157,6 +253,8 @@ const _ = grpc.SupportPackageIsVersion4
type QueryClient interface { type QueryClient interface {
// Parameters queries the parameters of the module. // Parameters queries the parameters of the module.
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
// Queries a list of Der items.
Der(ctx context.Context, in *QueryDerRequest, opts ...grpc.CallOption) (*QueryDerResponse, error)
} }
type queryClient struct { type queryClient struct {
@ -176,10 +274,21 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts .
return out, nil return out, nil
} }
func (c *queryClient) Der(ctx context.Context, in *QueryDerRequest, opts ...grpc.CallOption) (*QueryDerResponse, error) {
out := new(QueryDerResponse)
err := c.cc.Invoke(ctx, "/planetmintgo.der.Query/Der", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QueryServer is the server API for Query service. // QueryServer is the server API for Query service.
type QueryServer interface { type QueryServer interface {
// Parameters queries the parameters of the module. // Parameters queries the parameters of the module.
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
// Queries a list of Der items.
Der(context.Context, *QueryDerRequest) (*QueryDerResponse, error)
} }
// UnimplementedQueryServer can be embedded to have forward compatible implementations. // UnimplementedQueryServer can be embedded to have forward compatible implementations.
@ -189,6 +298,9 @@ type UnimplementedQueryServer struct {
func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
} }
func (*UnimplementedQueryServer) Der(ctx context.Context, req *QueryDerRequest) (*QueryDerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Der not implemented")
}
func RegisterQueryServer(s grpc1.Server, srv QueryServer) { func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv) s.RegisterService(&_Query_serviceDesc, srv)
@ -212,6 +324,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Query_Der_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryDerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).Der(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/planetmintgo.der.Query/Der",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Der(ctx, req.(*QueryDerRequest))
}
return interceptor(ctx, in, info, handler)
}
var Query_serviceDesc = _Query_serviceDesc var Query_serviceDesc = _Query_serviceDesc
var _Query_serviceDesc = grpc.ServiceDesc{ var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "planetmintgo.der.Query", ServiceName: "planetmintgo.der.Query",
@ -221,6 +351,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
MethodName: "Params", MethodName: "Params",
Handler: _Query_Params_Handler, Handler: _Query_Params_Handler,
}, },
{
MethodName: "Der",
Handler: _Query_Der_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "planetmintgo/der/query.proto", Metadata: "planetmintgo/der/query.proto",
@ -282,6 +416,71 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
func (m *QueryDerRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QueryDerRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryDerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.ZigbeeID) > 0 {
i -= len(m.ZigbeeID)
copy(dAtA[i:], m.ZigbeeID)
i = encodeVarintQuery(dAtA, i, uint64(len(m.ZigbeeID)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *QueryDerResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QueryDerResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryDerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Der != nil {
{
size, err := m.Der.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
offset -= sovQuery(v) offset -= sovQuery(v)
base := offset base := offset
@ -313,6 +512,32 @@ func (m *QueryParamsResponse) Size() (n int) {
return n return n
} }
func (m *QueryDerRequest) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.ZigbeeID)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
return n
}
func (m *QueryDerResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Der != nil {
l = m.Der.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
func sovQuery(x uint64) (n int) { func sovQuery(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7 return (math_bits.Len64(x|1) + 6) / 7
} }
@ -452,6 +677,174 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *QueryDerRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: QueryDerRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryDerRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ZigbeeID", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ZigbeeID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *QueryDerResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: QueryDerResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryDerResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Der", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Der == nil {
m.Der = &DER{}
}
if err := m.Der.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipQuery(dAtA []byte) (n int, err error) { func skipQuery(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0

View File

@ -51,6 +51,60 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
} }
func request_Query_Der_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDerRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["zigbeeID"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID")
}
protoReq.ZigbeeID, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err)
}
msg, err := client.Der(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Der_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDerRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["zigbeeID"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID")
}
protoReq.ZigbeeID, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err)
}
msg, err := server.Der(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly. // UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@ -80,6 +134,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
}) })
mux.Handle("GET", pattern_Query_Der_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Der_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Der_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@ -141,13 +218,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}) })
mux.Handle("GET", pattern_Query_Der_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
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_Query_Der_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Der_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
var ( var (
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"planetmint", "der", "params"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"planetmint", "der", "params"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_Der_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"planetmint", "der", "zigbeeID"}, "", runtime.AssumeColonVerbOpt(true)))
) )
var ( var (
forward_Query_Params_0 = runtime.ForwardResponseMessage forward_Query_Params_0 = runtime.ForwardResponseMessage
forward_Query_Der_0 = runtime.ForwardResponseMessage
) )