device.proto 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // define syntax used in proto file
  2. syntax = "proto3";
  3. // options used by gRPC golang plugin(not related to gRPC gateway)
  4. //option go_package = "github.com/osguydch/ccosproc";
  5. package Device.V3;
  6. // well know type by google, gRPC gateway uses HTTP annotation.
  7. import "google/api/annotations.proto";
  8. import "protoc-gen-openapiv2/options/annotations.proto";
  9. //import "third_party/googleapis/google/api/annotations.proto";
  10. // These annotations are used when generating the OpenAPI file.
  11. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  12. info: {version: "3.0"};
  13. external_docs: {
  14. url: "https://github.com/osguydch/ccosproc";
  15. description: "gRPC-gateway boilerplate repository";
  16. }
  17. schemes: HTTPS;
  18. };
  19. // simple message
  20. message OpenRequest {
  21. string deviceUri = 1;
  22. string deviceGroup = 2;
  23. }
  24. message OpenReply {
  25. string message = 1;
  26. string retCode = 2;
  27. string retContext = 3;
  28. }
  29. message DoRequest{
  30. string deviceUri = 1;
  31. string reqName = 2;
  32. string reqParam = 3;
  33. string reqTransaction = 4;
  34. string reqClientID = 5;
  35. }
  36. message DoResponse{
  37. string deviceUri = 1;
  38. string retCode = 2;
  39. string reqName = 3;
  40. string respResult = 4;
  41. string reqTransaction = 5;
  42. string retContext = 6;
  43. }
  44. // a gRPC service
  45. service Device {
  46. // Open is a rpc call and a option is defined for it
  47. rpc Open (OpenRequest) returns (OpenReply) {
  48. // option type is http
  49. option (google.api.http) = {
  50. // this is url, for RESTfull/JSON api and method
  51. // this line means when a HTTP post request comes with "/v1/Device/Open" call this rpc method over this service
  52. post: "/api/v1/Device/Open"
  53. body: "*"
  54. };
  55. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  56. summary: "Open a Deivce"
  57. description: "Open Device from Platform."
  58. tags: "Device"
  59. };
  60. };
  61. rpc Close (OpenRequest) returns (OpenReply) {
  62. // option type is http
  63. option (google.api.http) = {
  64. // this is url, for RESTfull/JSON api and method
  65. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  66. post: "/api/v1/Device/Close"
  67. body: "*"
  68. };
  69. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  70. summary: "Close Opened Deivce"
  71. description: "Close Device from Platform."
  72. tags: "Device"
  73. };
  74. };
  75. rpc Get (DoRequest) returns (DoResponse) {
  76. // option type is http
  77. option (google.api.http) = {
  78. // this is url, for RESTfull/JSON api and method
  79. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  80. get: "/api/v1/Device/Get/{reqName}"
  81. };
  82. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  83. summary: "Get Properties Value from Deivce"
  84. description: "Get Properties Value from Deivce Platform."
  85. tags: "Device"
  86. };
  87. };
  88. rpc Set (DoRequest) returns (DoResponse) {
  89. // option type is http
  90. option (google.api.http) = {
  91. // this is url, for RESTfull/JSON api and method
  92. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  93. put: "/api/v1/Device/Set/{reqName}"
  94. };
  95. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  96. summary: "Set Properties Value from Deivce"
  97. description: "Set Properties Value from Deivce Platform."
  98. tags: "Device"
  99. };
  100. };
  101. rpc Update (DoRequest) returns (DoResponse) {
  102. // option type is http
  103. option (google.api.http) = {
  104. // this is url, for RESTfull/JSON api and method
  105. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  106. post: "/api/v1/Device/Update/{reqName}"
  107. body: "*"
  108. };
  109. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  110. summary: "Update Properties Value for Deivce, effort immediately"
  111. description: "Update Properties Value for Deivce at Platform."
  112. tags: "Device"
  113. };
  114. };
  115. rpc Add (DoRequest) returns (DoResponse) {
  116. // option type is http
  117. option (google.api.http) = {
  118. // this is url, for RESTfull/JSON api and method
  119. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  120. post: "/api/v1/Device/Add/{reqName}"
  121. body: "*"
  122. };
  123. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  124. summary: "Add Properties Value for Deivce"
  125. description: "Add Properties Value for Deivce at Platform if Property canbe added."
  126. tags: "Device"
  127. };
  128. };
  129. rpc Del (DoRequest) returns (DoResponse) {
  130. // option type is http
  131. option (google.api.http) = {
  132. // this is url, for RESTfull/JSON api and method
  133. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  134. delete: "/api/v1/Device/Del/{reqName}"
  135. };
  136. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  137. summary: "Delete Properties Value for Deivce"
  138. description: "Delete Properties Value for Deivce at Platform if Property canbe deleted."
  139. tags: "Device"
  140. };
  141. };
  142. rpc Action (DoRequest) returns (DoResponse) {
  143. // option type is http
  144. option (google.api.http) = {
  145. // this is url, for RESTfull/JSON api and method
  146. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  147. post: "/api/v1/Device/Action/{reqName}"
  148. body: "*"
  149. };
  150. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  151. summary: "Execuate Action for Deivce"
  152. description: "Execuate Action for Deivce at Platform ."
  153. tags: "Device"
  154. };
  155. };
  156. rpc Message (DoRequest) returns (DoResponse) {
  157. // option type is http
  158. option (google.api.http) = {
  159. // this is url, for RESTfull/JSON api and method
  160. // this line means when a HTTP post request comes with "/v1/Device/Close" call this rpc method over this service
  161. post: "/api/v1/Device/Message"
  162. body: "*"
  163. };
  164. option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
  165. summary: "Send Message to Deivce"
  166. description: "Send Message to Deivce at Platform "
  167. tags: "Device"
  168. };
  169. };
  170. }