// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

syntax = "proto3";

import "google/api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/field_mask.proto";

package transcoding;

service JsonTranscodingGreeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
    };
  }
  rpc ResponseBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
      response_body: "message"
    };
  }
  rpc Custom (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      custom: {
        kind: "HEAD",
        path: "/v1/greeter/{name}"
      }
    };
  }
  rpc AdditionalBindings (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/additional_bindings/{name}"
      additional_bindings {
        delete: "/v1/additional_bindings/{name}"
      }
    };
  }
  rpc NoOption (HelloRequest) returns (HelloReply);
  rpc ServerStreamingGetOption (HelloRequest) returns (stream HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
    };
  }
  rpc Body (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/greeter"
      body: "*"
    };
  }
  rpc SubBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/greeter"
      body: "sub"
    };
  }
  rpc SubRepeatedBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/greeter"
      body: "repeated_strings"
    };
  }
}

service JsonTranscodingInvalidResponseBodyGreeter {
  rpc BadResponseBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
      response_body: "NoMatch"
    };
  }
}

service JsonTranscodingInvalidNestedResponseBodyGreeter {
  rpc BadResponseBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
      response_body: "sub.subfield"
    };
  }
}

service JsonTranscodingInvalidBodyGreeter {
  rpc BadBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
      body: "NoMatch"
    };
  }
}

service JsonTranscodingInvalidNestedBodyGreeter {
  rpc BadBody (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/greeter/{name}"
      body: "sub.subfield"
    };
  }
}

service JsonTranscodingInvalidPatternGreeter {
  rpc BadPattern (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "v1/greeter/{name}"
      body: "NoMatch"
    };
  }
}

service JsonTranscodingStreaming {
  rpc GetServerStreaming (HelloRequest) returns (stream HelloReply) {
    option (google.api.http) = {
      get: "/v1/server_greeter/{name}"
    };
  }
  rpc GetClientStreaming (stream HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      get: "/v1/client_greeter/{name}"
    };
  }
  rpc GetBidiStreaming (stream HelloRequest) returns (stream HelloReply) {
    option (google.api.http) = {
      get: "/v1/bidi_greeter/{name}"
    };
  }
}

service JsonTranscodingColonRoute {
  rpc StartFrameImport(HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/frames:startFrameImport",
      body: "*",
    };
  }
  rpc GetFrameImport(HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/frames:getFrameImport",
      body: "*",
    };
  }
}

message HelloRequest {
  message SubMessage {
    string subfield = 1;
    repeated string subfields = 2;
  }
  message DataTypes {
    enum NestedEnum {
      NESTED_ENUM_UNSPECIFIED = 0;
      FOO = 1;
      BAR = 2;
      BAZ = 3;
      NEG = -1;  // Intentionally negative.
    }
    message NestedMessage {
      string subfield = 1;
    }
    int32 single_int32 = 1;
    int64 single_int64 = 2;
    uint32 single_uint32 = 3;
    uint64 single_uint64 = 4;
    sint32 single_sint32 = 5;
    sint64 single_sint64 = 6;
    fixed32 single_fixed32 = 7;
    fixed64 single_fixed64 = 8;
    sfixed32 single_sfixed32 = 9;
    sfixed64 single_sfixed64 = 10;
    float single_float = 11;
    double single_double = 12;
    bool single_bool = 13;
    string single_string = 14;
    bytes single_bytes = 15;
    NestedEnum single_enum = 16;
    NestedMessage single_message = 17;
  }
  message Wrappers {
    google.protobuf.StringValue string_value = 1;
    google.protobuf.Int32Value int32_value = 2;
    google.protobuf.Int64Value int64_value = 3;
    google.protobuf.FloatValue float_value = 4;
    google.protobuf.DoubleValue double_value = 5;
    google.protobuf.BoolValue bool_value = 6;
    google.protobuf.UInt32Value uint32_value = 7;
    google.protobuf.UInt64Value uint64_value = 8;
    google.protobuf.BytesValue bytes_value = 9;
  }
  string name = 1;
  SubMessage sub = 2;
  DataTypes data = 3;
  Wrappers wrappers = 4;
  repeated string repeated_strings = 5;
  google.protobuf.Any any_message = 6;
  map<string, string> map_strings = 7;
  map<string, SubMessage> map_message = 8;
  map<bool, string> map_keybool = 9;
  map<int32, string> map_keyint = 10;
  oneof oneof_test {
      string oneof_name1 = 11;
      string oneof_name2 = 12;
  }
  int32 age = 13;
  repeated google.protobuf.DoubleValue repeated_double_values = 14;
  google.protobuf.Timestamp timestamp_value = 15;
  google.protobuf.Duration duration_value = 16;
  google.protobuf.Value value_value = 17;
  google.protobuf.Struct struct_value = 18;
  google.protobuf.ListValue list_value = 19;
  google.protobuf.NullValue null_value = 20;
  google.protobuf.FieldMask field_mask_value = 21;
  string field_name = 22 [json_name="json_customized_name"];
  google.protobuf.FloatValue float_value = 23;
  string hiding_field_name = 24 [json_name="field_name"];
  repeated SubMessage repeated_messages = 25;
  map<int32, int32> map_keyint_valueint = 26;
  SubMessage sub_data = 27;
}

message HelloReply {
  message SubMessage {
    string subfield = 1;
    repeated string subfields = 2;
  }
  string message = 1;
  repeated string values = 2;
  google.protobuf.StringValue nullable_message = 3;
  google.protobuf.Any any_message = 4;
  SubMessage sub = 5;
}

message NullValueContainer {
  google.protobuf.NullValue null_value = 1;
}
