// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You 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.

message TestRequest{
	required int32 index = 1;
	required User user = 2;
	required bytes data = 3;
	//repeated MapFieldEntry friends = 4;
}

message User{
	required string name = 1;
	required int32 age = 2;
	required int32 index = 3;
	//repeated MapFieldEntry friends = 4;
}

message MapFieldEntry {
  required string key = 1;
  required int32 value = 2;
}

message TestResponse{
	required User user = 1;
}

enum EnumType {
    ONE = 0;
    TWO = 1;
}

message EnumMessage{
	required EnumType enumType = 1;
}

message Empty{
}

message MicroService{
    optional string service_id = 1;
    required string app_id = 2;
    required string name = 3;
    required string version = 4;
    optional string description = 5;
    optional string level = 6 [default = "front"];
    repeated ServiceDefinition definitions = 7;
    optional ServiceStatus status = 8 [default = INSERVICE];
}

message ServiceDefinition {
    required string name = 1;
    required string version = 2;
    required string transport = 3;
    repeated string schema = 4;
    //map<string, string> properties = 5;
}

enum ServiceStatus {
    INSERVICE = 0;
    OUTOFSERVICE = 1;
}

message MicroServiceWrap{
	required MicroService service = 1;
}

service server {
	rpc splitParam(TestRequest) returns(User);
	rpc standard(TestRequest) returns(TestResponse);
	rpc sayHello (HelloRequest) returns (HelloReply);
	rpc standardSayHello (HelloRequest) returns (HelloReply);
	rpc testEnum(EnumMessage) returns(EnumMessage);
	rpc testStandardEnum(EnumMessage) returns(EnumMessage);
	rpc testEmpty(Empty) returns(Empty);
	rpc testMicroService(MicroService) returns(MicroService);
	rpc testCreateMicroService(MicroServiceWrap) returns(MicroServiceWrap);
}

message HelloRequest {
	required string name = 1;
}

message HelloReply {
	required string message = 1;
}
