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

add google.api.field_behavior optional/mandatory #198

Closed
glimchb opened this issue Nov 8, 2022 · 5 comments
Closed

add google.api.field_behavior optional/mandatory #198

glimchb opened this issue Nov 8, 2022 · 5 comments
Assignees
Labels
Storage APIs or code related to storage area

Comments

@glimchb
Copy link
Member

glimchb commented Nov 8, 2022

see https://linter.aip.dev/203/optional and https://google.aip.dev/203
example:

diff --git a/storage/v1alpha1/frontend_nvme_pcie.proto b/storage/v1alpha1/frontend_nvme_pcie.proto
index 610239e..303b684 100755
--- a/storage/v1alpha1/frontend_nvme_pcie.proto
+++ b/storage/v1alpha1/frontend_nvme_pcie.proto
@@ -15,8 +15,10 @@ import "object_key.proto";
 import "uuid.proto";
 import "google/protobuf/empty.proto";
 import "google/api/annotations.proto";
+import "google/api/field_behavior.proto";

 // Front End (host-facing) APIs. Mostly used for NVMe/PCIe emulation and host presentation.
+
 service FrontendNvmeService {
     rpc NVMeSubsystemCreate (NVMeSubsystemCreateRequest) returns (NVMeSubsystem) {
         option (google.api.http) = {
@@ -151,7 +153,7 @@ message NVMeController {

     // maximum number of host completion queues allowed.
     // If not set, the xPU will provide a default.
-    int32 max_ncq = 6;
+    int32 max_ncq = 6 [(google.api.field_behavior) = OPTIONAL];

     // maximum number of submission queue entries per submission queue, as a power of 2.
     // default value as per spec is 6
@@ -195,7 +197,7 @@ message NVMeNamespace {

     // 64bit Extended unique identifier for the namespace
     // mandatory if guid is not specified
-    int64 eui64 = 8;
+    int64 eui64 = 8 [(google.api.field_behavior) = OPTIONAL];

     // Globally unique identifier for the namespace
     common.v1.Uuid uuid = 9;
(END)
@glimchb glimchb added the Storage APIs or code related to storage area label Nov 8, 2022
@glimchb glimchb changed the title add google.api.field_behavior add google.api.field_behavior optional/mandatory Nov 8, 2022
@glimchb glimchb added the good first issue Good for newcomers label Nov 8, 2022
@jainvipin
Copy link
Contributor

I am curious about the intent of this issue:

  • is suggesting that we use google.api.field_behavior to specify optional fields or use protobuf optional parameter, which specifies the protobuf encoding
  • Is it suggesting that we we start labeling optional(and therefore mandator to the unlabeled fields) to currently defined APIs?

@glimchb
Copy link
Member Author

glimchb commented Nov 15, 2022

Yes, Suggesting that we start labeling optional (and therefore mandatory to the unlabeled fields) to currently defined APIs

@artek-koltun
Copy link
Contributor

REQUIRED annotation is definitely useful. In conjunction with fieldbehavior.ValidateRequiredFields it can be a relative protection against nil pointer dereference in requests.

@glimchb
Copy link
Member Author

glimchb commented Aug 14, 2023

frontend added by @artek-koltun #321

@glimchb glimchb closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage APIs or code related to storage area
Projects
None yet
Development

No branches or pull requests

3 participants