syntax = "proto3"; package api.v1; option go_package = "github.com/henvic/pgxtutorial/internal/apiv1/apipb"; option java_multiple_files = true; option java_outer_classname = "APIProto"; option java_package = "api.v1"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; // Inventory gRPC API service. service Inventory { // ListProducts returns a list of products. rpc ListProducts (ListProductsRequest) returns (ListProductsResponse) { option (google.api.http) = { get: "/v1/products" }; } // SearchProducts returns a search of products. rpc SearchProducts (SearchProductsRequest) returns (SearchProductsResponse) { option (google.api.http) = { post: "/v1/products:search", body: "*" }; } // CreateProduct creates a product in the inventory. rpc CreateProduct (CreateProductRequest) returns (Product) { option (google.api.method_signature) = "product"; option (google.api.http) = { post: "/v1/products" body: "product" }; } // UpdateProduct updates an inventory product. rpc UpdateProduct (UpdateProductRequest) returns (Product) { option (google.api.method_signature) = "product,update_mask"; option (google.api.http) = { patch: "/v1/products/{product.name=products/*}", body: "product" }; } // DeleteProduct from the inventory. rpc DeleteProduct (DeleteProductRequest) returns (google.protobuf.Empty) { option (google.api.method_signature) = "name"; option (google.api.http) = { delete: "/v1/products/{name=products/*}" }; } // GetProduct from the inventory. rpc GetProduct (GetProductRequest) returns (Product) { option (google.api.method_signature) = "name"; option (google.api.http) = { get: "/v1/products/{name=products/*}" }; } // ListProductReview returns a list of products reviews. rpc ListProductsReviews (ListProductsReviewsRequest) returns (ListProductsReviewsResponse) { option (google.api.method_signature) = "parent"; option (google.api.http) = { get: "/v1/{parent=products/*}/reviews" }; } // CreateProductReview creates a product review. rpc CreateProductReview (CreateProductReviewRequest) returns (ProductReview) { option (google.api.method_signature) = "parent,product_review,product_review_id"; option (google.api.http) = { post: "/v1/{parent=products/*}/reviews" body: "product_review" }; } // UpdateProductReview updates a product review. rpc UpdateProductReview (UpdateProductReviewRequest) returns (ProductReview) { option (google.api.method_signature) = "product_review,update_mask"; option (google.api.http) = { patch: "/v1/{product_review.name=products/*/reviews/*}", body: "product_review" }; } // DeleteProductReview deletes a product review. rpc DeleteProductReview (DeleteProductReviewRequest) returns (google.protobuf.Empty) { option (google.api.method_signature) = "name"; option (google.api.http) = { delete: "/v1/{name=products/*/reviews/*}" }; } // GetProductReview returns a product review. rpc GetProductReview (GetProductReviewRequest) returns (ProductReview) { option (google.api.method_signature) = "name"; option (google.api.http) = { get: "/v1/products/{name=products/*/reviews/*}" }; } } // Product message. message Product { option (google.api.resource) = { type: "inventory.pgxtutorial/Product" pattern: "products/{product}" plural: "products" singular: "product" }; // Name. string name = 3 [(google.api.field_behavior) = IDENTIFIER]; // Product ID. string product_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; // Price. int64 price = 2 [(google.api.field_behavior) = REQUIRED]; // Description. string description = 4 [(google.api.field_behavior) = REQUIRED]; // Created timestamp. string created = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; // Modified timestamp. string modified = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; } // ListProductsRequest message. message ListProductsRequest { // page_size is the number of products to return. int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; // page_token is the next page token. string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // ListProductsResponse message. message ListProductsResponse { // Products. repeated Product products = 1; // Next page token. string next_page_token = 2; } // SearchProductsRequest message. message SearchProductsRequest { // page_size is the number of products to return. int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; // page_token is the next page token. string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; // query_string is the search query. string query_string = 3 [(google.api.field_behavior) = REQUIRED]; // min_price is the minimum price. optional int64 min_price = 4 [(google.api.field_behavior) = OPTIONAL]; // max_price is the maximum price. optional int64 max_price = 5 [(google.api.field_behavior) = OPTIONAL]; } // SearchProductsResponse message. message SearchProductsResponse { // Products. repeated Product products = 1; // Next page token. string next_page_token = 2; // Total number of products. int32 total = 3; } // CreateProductRequest message. // (-- api-linter: core::0133::request-id-field=disabled // aip.dev/not-precedent: Product already contain ID. --) message CreateProductRequest { // Product content. Product product = 2 [(google.api.field_behavior) = REQUIRED]; } // UpdateProductRequest message. message UpdateProductRequest { // Product content. Product product = 1 [(google.api.field_behavior) = REQUIRED]; // Update mask. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; } // DeleteProductRequest message. message DeleteProductRequest { // Name of the product. string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/Product" ]; // Force delete even if there are existing product requests. bool force = 2 [(google.api.field_behavior) = OPTIONAL]; } // GetProductRequest message. message GetProductRequest { // Name of the product. string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/Product" ]; } // ProductReview message. message ProductReview { option (google.api.resource) = { type: "inventory.pgxtutorial/ProductReview" pattern: "products/{product}/reviews/{product_review}" plural: "productsReviews" singular: "productReview" }; // Name. string name = 1 [(google.api.field_behavior) = IDENTIFIER]; // Product Review ID. string product_review_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; // Product ID. string product_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; // Reviewer ID. string reviewer_id = 4 [(google.api.field_behavior) = REQUIRED]; // Score. int32 score = 5 [(google.api.field_behavior) = REQUIRED]; // Title. string title = 6 [(google.api.field_behavior) = REQUIRED]; // Description. string description = 7 [(google.api.field_behavior) = REQUIRED]; // Created timestamp. string created = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; // Modified timestamp. string modified = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; } // ListProductsReviewsRequest message. message ListProductsReviewsRequest { // Parent product ID. string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/Product" ]; // page_size is the number of products reviews to return. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; // page_token is the next page token. string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // ListProductsReviewsResponse message. message ListProductsReviewsResponse { // Products reviews. repeated ProductReview products_reviews = 1; // Next page token. string next_page_token = 2; } // CreateProductReviewRequest message. message CreateProductReviewRequest { // Product ID. string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/Product" ]; // Product Review ID. string product_review_id = 2 [(google.api.field_behavior) = REQUIRED]; // Product Review content. ProductReview product_review = 3 [(google.api.field_behavior) = REQUIRED]; } // UpdateProductReviewRequest message. message UpdateProductReviewRequest { // Product content. ProductReview product_review = 1 [(google.api.field_behavior) = REQUIRED]; // Update mask. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; } // DeleteProductReviewRequest message. message DeleteProductReviewRequest { // Name of the product review. string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/ProductReview" ]; // Force delete even if there are existing product requests. bool force = 2 [(google.api.field_behavior) = OPTIONAL]; } // GetProductReviewRequest message. message GetProductReviewRequest { // Name of the product review. string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference).type = "inventory.pgxtutorial/ProductReview" ]; }