Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Google.Api.Http option instead of custom option #13

Open
taliesins opened this issue Jun 30, 2017 · 1 comment
Open

Use Google.Api.Http option instead of custom option #13

taliesins opened this issue Jun 30, 2017 · 1 comment

Comments

@taliesins
Copy link

taliesins commented Jun 30, 2017

Perhaps it would be better to use the Google Extensions for Http Rule instead of creating a custom one.

syntax = "proto3";

package GrpcExample;

import "google/api/annotations.proto";

message Quoted {
  int64 id = 1;
}

message QuotedProduct {
  PriceComponent quotedPrice = 100;
}

message Product {
  string code = 1;
  string name = 2;
  QuotedProduct quotedProduct = 3;  
}

message Ordered {
  int64 id = 1;
  repeated QuotedProduct products = 2;
  enum Status {
    placed = 0;
    approved = 1;
    delivered = 2;
  }
  Status status = 3; //Order Status
  bool complete = 4;
}

message PriceComponent {
  double amount = 1;
  string currency = 2;
}

message PlaceQuoteRequest{
    Quoted quoted = 1;
}

message PlaceQuoteResponse{
}

message GetOrderRequest{
    int64 orderId = 1; //ID of pet that needs to be fetched
}

message GetOrderResponse{
  Ordered ordered = 1;
}

message DeleteOrderRequest{
  int64 orderId = 1; //ID of the order that needs to be deleted
}

message DeleteOrderResponse{
  Ordered ordered = 1;
}

service Order {
  /* Place an order for quoting */
  rpc PlaceQuote(PlaceQuoteRequest) returns (PlaceQuoteResponse) {
    option (google.api.http) = {
      post: "/v2/store/order/quote"
      body: "*"
    };
  }
  
  /* Find purchase order by ID */
  rpc GetOrder(GetOrderRequest) returns (GetOrderResponse) {
    option (google.api.http) = {
      get: "/v2/store/order/{orderId}"
    };
  }

  /* Delete purchase order by ID */
  rpc DeleteOrder(DeleteOrderRequest) returns (DeleteOrderResponse) {
    option (google.api.http) = {
      delete: "/v2/store/order/{orderId}"
    };
  }
}
@GuoJing
Copy link
Collaborator

GuoJing commented Jul 24, 2017

Thanks, let's think about this. @zhongql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants