github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/testpb/test.proto (about)

     1  // Copyright 2021 Edward McFarlane. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  syntax = "proto3";
     6  
     7  package larking.testpb;
     8  
     9  import "google/api/annotations.proto";
    10  import "google/api/httpbody.proto";
    11  import "google/protobuf/timestamp.proto";
    12  import "google/protobuf/duration.proto";
    13  import "google/protobuf/field_mask.proto";
    14  import "google/protobuf/empty.proto";
    15  import "google/protobuf/wrappers.proto";
    16  
    17  option go_package = "github.com/emcfarlane/larking/testpb;testpb";
    18  
    19  service Messaging {
    20    // HTTP | gRPC
    21    // -----|-----
    22    // `GET /v1/messages/123456`  | `GetMessageOne(name: "messages/123456")`
    23    rpc GetMessageOne(GetMessageRequestOne) returns (Message) {
    24      option (google.api.http) = {
    25        get : "/v1/messages/{name=name/*}"
    26      };
    27    }
    28  
    29    // HTTP | gRPC
    30    // -----|-----
    31    // `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
    32    // `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
    33    // "foo"))`
    34    // `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
    35    // "123456")`
    36    rpc GetMessageTwo(GetMessageRequestTwo) returns (Message) {
    37      option (google.api.http) = {
    38        get : "/v1/messages/{message_id}"
    39        additional_bindings {get : "/v1/users/{user_id}/messages"}
    40        additional_bindings {get : "/v1/users/{user_id}/messages/{message_id}"}
    41      };
    42    }
    43  
    44    // HTTP | gRPC
    45    // -----|-----
    46    // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
    47    // "123456" message { text: "Hi!" })`
    48    rpc UpdateMessage(UpdateMessageRequestOne) returns (Message) {
    49      option (google.api.http) = {
    50        patch : "/v1/messages/{message_id}"
    51        body : "message"
    52      };
    53    }
    54  
    55    // HTTP | gRPC
    56    // -----|-----
    57    // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
    58    // "123456" text: "Hi!")`
    59    rpc UpdateMessageBody(Message) returns (Message) {
    60      option (google.api.http) = {
    61        patch : "/v1/messages/{message_id}/body"
    62        body : "*"
    63      };
    64    }
    65  
    66    rpc Action(Message) returns (google.protobuf.Empty) {
    67      option (google.api.http) = {
    68        post : "/v1/{text=action}:cancel"
    69        body : "*"
    70      };
    71    }
    72  
    73    rpc ActionSegment(Message) returns (google.protobuf.Empty) {
    74      option (google.api.http) = {
    75        post : "/v1/{text=*}:clear"
    76        body : "*"
    77      };
    78    }
    79  
    80    rpc ActionResource(Message) returns (google.protobuf.Empty) {
    81      option (google.api.http) = {
    82        get : "/v1/{text=actions/*}:fetch"
    83      };
    84    }
    85  
    86    rpc ActionSegments(Message) returns (google.protobuf.Empty) {
    87      option (google.api.http) = {
    88        post : "/v1/{text=**}:watch"
    89        body : "*"
    90      };
    91    }
    92  
    93    rpc BatchGet(google.protobuf.Empty) returns (google.protobuf.Empty) {
    94      // The batch get method maps to HTTP GET verb.
    95      option (google.api.http) = {
    96        get : "/v3/events:batchGet"
    97      };
    98    }
    99  
   100    rpc VariableOne(Message) returns (google.protobuf.Empty) {
   101      option (google.api.http) = {
   102        get : "/{text}/one"
   103      };
   104    }
   105    rpc VariableTwo(Message) returns (google.protobuf.Empty) {
   106      option (google.api.http) = {
   107        get : "/{text}/two"
   108      };
   109    }
   110  
   111    rpc GetShelf(GetShelfRequest) returns (Shelf) {
   112      option (google.api.http) = {
   113        get : "/v1/{name=shelves/*}"
   114      };
   115    };
   116    rpc GetBook(GetBookRequest) returns (Book) {
   117      option (google.api.http) = {
   118        get : "/v1/{name=shelves/*/books/*}"
   119      };
   120    };
   121    rpc CreateBook(CreateBookRequest) returns (Book) {
   122      option (google.api.http) = {
   123        post : "/v1/{parent=shelves/*}/books"
   124        body : "book"
   125      };
   126    };
   127    rpc UpdateBook(UpdateBookRequest) returns (Book) {
   128      // Update maps to HTTP PATCH. Resource name is mapped to a URL path.
   129      // Resource is contained in the HTTP request body.
   130      option (google.api.http) = {
   131        // Note the URL template variable which captures the resource name of the
   132        // book to update.
   133        patch : "/v1/{book.name=shelves/*/books/*}"
   134        body : "book"
   135      };
   136    }
   137  }
   138  
   139  message Message {
   140    string message_id = 1;
   141    string text = 2; // The resource content
   142    string user_id = 3;
   143  }
   144  message GetMessageRequestOne {
   145    string name = 1; // Mapped to URL path
   146  }
   147  message GetMessageRequestTwo {
   148    message SubMessage { string subfield = 1; }
   149    string message_id = 1; // Mapped to URL path
   150    int64 revision = 2;    // Mapped to URL query parameter `revision`
   151    SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`
   152    string user_id = 4;    // Additional binding
   153  }
   154  message UpdateMessageRequestOne {
   155    string message_id = 1; // Mapped to the URL
   156    Message message = 2;   // Mapped to the body
   157  }
   158  
   159  service Files {
   160    // HTTP | gRPC
   161    // -----|-----
   162    // `POST /files/cat.jpg <body>` | `UploadDownload(filename: "cat.jpg", file:
   163    // { content_type: "image/jpeg", data: <body>})"`
   164    rpc UploadDownload(UploadFileRequest) returns (google.api.HttpBody) {
   165      option (google.api.http) = {
   166        post : "/files/{filename}"
   167        body : "file"
   168      };
   169    }
   170    rpc LargeUploadDownload(stream UploadFileRequest)
   171        returns (stream google.api.HttpBody) {
   172      option (google.api.http) = {
   173        post : "/files/large/{filename}"
   174        body : "file"
   175      };
   176    }
   177  }
   178  message UploadFileRequest {
   179    string filename = 1;
   180    google.api.HttpBody file = 2;
   181  }
   182  
   183  // Valid a-z A-Z 0-9 . - _ ~ ! $ & ' ( ) * + , ; = : @
   184  service WellKnown {
   185    // HTTP | gRPC
   186    // -----|-----
   187    // `GET /v1/wellknown/timestamp/2017-01-15T01:30:15.01Z` |
   188    // `Check(Timestamp{...})`
   189    rpc Check(Scalars) returns (google.protobuf.Empty) {
   190      option (google.api.http) = {
   191        get : "/v1/wellknown"
   192      };
   193    }
   194  }
   195  
   196  message Scalars {
   197    google.protobuf.Timestamp timestamp = 1;
   198    google.protobuf.Duration duration = 2;
   199    google.protobuf.BoolValue bool_value = 3;
   200    google.protobuf.Int32Value int32_value = 4;
   201    google.protobuf.Int64Value int64_value = 5;
   202    google.protobuf.UInt32Value uint32_value = 6;
   203    google.protobuf.UInt64Value uint64_value = 7;
   204    google.protobuf.FloatValue float_value = 8;
   205    google.protobuf.DoubleValue double_value = 9;
   206    google.protobuf.BytesValue bytes_value = 10;
   207    google.protobuf.StringValue string_value = 11;
   208    google.protobuf.FieldMask field_mask = 12;
   209  }
   210  
   211  message Shelf {
   212    // Resource name of the shelf. It must have the format of "shelves/*".
   213    // For example: "shelves/shelf1".
   214    string name = 1;
   215  }
   216  
   217  message GetShelfRequest {
   218    // Resource name of a shelf. For example: "shelves/shelf1".
   219    string name = 1;
   220  }
   221  
   222  message Book {
   223    // Resource name of the book. It must have the format of "shelves/*/books/*".
   224    // For example: "shelves/shelf1/books/book2".
   225    string name = 1;
   226  
   227    // ... other properties
   228    string title = 2;
   229  }
   230  
   231  message GetBookRequest {
   232    // Resource name of a book. For example: "shelves/shelf1/books/book2".
   233    string name = 1;
   234  }
   235  
   236  message CreateBookRequest {
   237    // Resource name of the parent resource where to create the book.
   238    // For example: "shelves/shelf1".
   239    string parent = 1;
   240    // The Book resource to be created. Client must not set the `Book.name` field.
   241    Book book = 2;
   242  }
   243  
   244  message UpdateBookRequest {
   245    // The book resource which replaces the resource on the server.
   246    Book book = 1;
   247  
   248    // The update mask applies to the resource. For the `FieldMask` definition,
   249    // see
   250    // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
   251    google.protobuf.FieldMask update_mask = 2;
   252  }
   253  
   254  message ChatMessage {
   255    string name = 1;
   256    string text = 2;
   257  }
   258  
   259  // Chatroom shows the websocket extension.
   260  service ChatRoom {
   261    rpc Chat(stream ChatMessage) returns (stream ChatMessage) {
   262      option (google.api.http) = {
   263        custom : {kind : "websocket" path : "/v1/{name=rooms/*}"}
   264        body : "*"
   265      };
   266    }
   267  }