diff --git a/aip/cloud/25001.md b/aip/cloud/25001.md new file mode 100644 index 0000000000..21bf86efda --- /dev/null +++ b/aip/cloud/25001.md @@ -0,0 +1,66 @@ +--- +id: 25001 +state: draft +created: TBD +placement: + category: gcp +--- + +# Empty Objects + +Fields of type Message **must not** be empty. Empty messages do not have uniform + +## Alternatives + +The presence of empty Messages are sometimes used to indicate that a flag is enabled. Alternatives to empty Messages could include a single boolean field within the Message to signify enablement or an Enum rather than an empty Message. + +### Add Field to Message +For example: +```proto +message EnableMyFeature { +} +``` +Could be modeled instead as: + +```proto +message MyFeature { + bool enabled = 1; +} +``` + +### Move Option to Top-Level Enum + +For a situation where the presence of an empty Message indicates a certain option is being chosen, an alternative is to choose the option via an enum rather than the presence of a particular object. + +For example: +```proto +oneof access_model { + AccessModelFree free = 1 + AccessModelQuota quota = 2 +} + +message AccessModelFree { +} + +message AccessModelQuota { + int32 requests_per_day = 1; +} +``` + +Could be modeled instead as: +```proto +enum AccessModel { + UNSPECIFIED = 0; + FREE = 1; + QUOTA = 1; +} + +message AccessModelQuota { + int32 requests_per_day = 1; +} +``` + + +## Changelog + +- **TBD**: Created