...

Text file src/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/echo_service.proto

Documentation: github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb

     1syntax = "proto3";
     2
     3// Echo Service
     4//
     5// Echo Service API consists of a single service which returns
     6// a message.
     7package grpc.gateway.examples.internal.proto.examplepb;
     8
     9import "google/api/annotations.proto";
    10import "google/protobuf/field_mask.proto";
    11import "google/protobuf/struct.proto";
    12
    13option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb";
    14
    15// Embedded represents a message embedded in SimpleMessage.
    16message Embedded {
    17  oneof mark {
    18    int64 progress = 1;
    19    string note = 2;
    20  }
    21}
    22
    23message NestedMessage {
    24  string n_id = 1;
    25  string val = 2;
    26}
    27
    28// SimpleMessage represents a simple message sent to the Echo service.
    29message SimpleMessage {
    30  // Id represents the message identifier.
    31  string id = 1;
    32  int64 num = 2;
    33  oneof code {
    34    int64 line_num = 3;
    35    string lang = 4;
    36  }
    37  Embedded status = 5;
    38  oneof ext {
    39    int64 en = 6;
    40    Embedded no = 7;
    41  }
    42  string resource_id = 8;
    43  NestedMessage n_id = 9;
    44}
    45
    46// DynamicMessage represents a message which can have its structure
    47// built dynamically using Struct and Values.
    48message DynamicMessage {
    49  google.protobuf.Struct struct_field = 1;
    50  google.protobuf.Value value_field = 2;
    51}
    52
    53message DynamicMessageUpdate {
    54  DynamicMessage body = 1;
    55  google.protobuf.FieldMask update_mask = 2;
    56}
    57
    58// Echo service responds to incoming echo requests.
    59service EchoService {
    60  // Echo method receives a simple message and returns it.
    61  //
    62  // The message posted as the id parameter will also be
    63  // returned.
    64  rpc Echo(SimpleMessage) returns (SimpleMessage) {
    65    option (google.api.http) = {
    66      post: "/v1/example/echo/{id}"
    67      additional_bindings {get: "/v1/example/echo/{id}/{num}"}
    68      additional_bindings {get: "/v1/example/echo/{id}/{num}/{lang}"}
    69      additional_bindings {get: "/v1/example/echo1/{id}/{line_num}/{status.note}"}
    70      additional_bindings {get: "/v1/example/echo2/{no.note}"}
    71      additional_bindings {get: "/v1/example/echo/resource/{resource_id}"}
    72      additional_bindings {get: "/v1/example/echo/nested/{n_id.n_id}"}
    73    };
    74  }
    75  // EchoBody method receives a simple message and returns it.
    76  rpc EchoBody(SimpleMessage) returns (SimpleMessage) {
    77    option (google.api.http) = {
    78      post: "/v1/example/echo_body"
    79      body: "*"
    80      additional_bindings {
    81        put: "/v1/example/echo_body/{id}"
    82        body: "no"
    83      }
    84    };
    85  }
    86  // EchoDelete method receives a simple message and returns it.
    87  rpc EchoDelete(SimpleMessage) returns (SimpleMessage) {
    88    option (google.api.http) = {delete: "/v1/example/echo_delete"};
    89  }
    90  // EchoPatch method receives a NonStandardUpdateRequest and returns it.
    91  rpc EchoPatch(DynamicMessageUpdate) returns (DynamicMessageUpdate) {
    92    option (google.api.http) = {
    93      patch: "/v1/example/echo_patch"
    94      body: "body"
    95    };
    96  }
    97  // EchoUnauthorized method receives a simple message and returns it. It must
    98  // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code
    99  // of 401.
   100  rpc EchoUnauthorized(SimpleMessage) returns (SimpleMessage) {
   101    option (google.api.http) = {get: "/v1/example/echo_unauthorized"};
   102  }
   103}

View as plain text