From e9b56d3e2235548c1ab51f788028579d31012aa4 Mon Sep 17 00:00:00 2001 From: Nathan McKinley Date: Thu, 6 Aug 2020 10:50:41 -0700 Subject: [PATCH] Convert inboundServices to an enum. (#3820) --- products/appengine/api.yaml | 32 ++++++++++++++++--- .../terraform/flatten_property_method.erb | 2 +- templates/terraform/schema_property.erb | 7 +++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/products/appengine/api.yaml b/products/appengine/api.yaml index a7e6987ec445..5bb077aaae9a 100644 --- a/products/appengine/api.yaml +++ b/products/appengine/api.yaml @@ -461,8 +461,20 @@ objects: - !ruby/object:Api::Type::Array name: 'inboundServices' description: | - Before an application can receive email or XMPP messages, the application must be configured to enable the service. - item_type: Api::Type::String + A list of the types of messages that this application is able to receive. + item_type: !ruby/object:Api::Type::Enum + name: 'inboundService' + description: | + One type of message that this application is able to receive. + values: + - :INBOUND_SERVICE_MAIL + - :INBOUND_SERVICE_MAIL_BOUNCE + - :INBOUND_SERVICE_XMPP_ERROR + - :INBOUND_SERVICE_XMPP_MESSAGE + - :INBOUND_SERVICE_XMPP_SUBSCRIBE + - :INBOUND_SERVICE_XMPP_PRESENCE + - :INBOUND_SERVICE_CHANNEL_PRESENCE + - :INBOUND_SERVICE_WARMUP - !ruby/object:Api::Type::String name: 'instanceClass' description: | @@ -631,8 +643,20 @@ objects: - !ruby/object:Api::Type::Array name: 'inboundServices' description: | - Before an application can receive email or XMPP messages, the application must be configured to enable the service. - item_type: Api::Type::String + A list of the types of messages that this application is able to receive. + item_type: !ruby/object:Api::Type::Enum + name: 'inboundService' + description: | + One type of message that this application is able to receive. + values: + - :INBOUND_SERVICE_MAIL + - :INBOUND_SERVICE_MAIL_BOUNCE + - :INBOUND_SERVICE_XMPP_ERROR + - :INBOUND_SERVICE_XMPP_MESSAGE + - :INBOUND_SERVICE_XMPP_SUBSCRIBE + - :INBOUND_SERVICE_XMPP_PRESENCE + - :INBOUND_SERVICE_CHANNEL_PRESENCE + - :INBOUND_SERVICE_WARMUP - !ruby/object:Api::Type::String name: 'instanceClass' description: | diff --git a/templates/terraform/flatten_property_method.erb b/templates/terraform/flatten_property_method.erb index 70e6d46b7ab0..d16691e0f447 100644 --- a/templates/terraform/flatten_property_method.erb +++ b/templates/terraform/flatten_property_method.erb @@ -123,7 +123,7 @@ func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d } <% if !property.set_hash_func.nil? -%> return schema.NewSet(<%= property.set_hash_func -%>, v.([]interface{})) - <% elsif property.item_type.is_a?(String) -%> + <% elsif property.item_type.is_a?(String) or property.item_type.is_a?(Api::Type::Enum) -%> return schema.NewSet(schema.HashString, v.([]interface{})) <% else raise 'Unknown hash function for property #{property.name}' -%> <% end -%> diff --git a/templates/terraform/schema_property.erb b/templates/terraform/schema_property.erb index 6e4fcbbdf828..5054d888b6f4 100644 --- a/templates/terraform/schema_property.erb +++ b/templates/terraform/schema_property.erb @@ -115,6 +115,11 @@ Elem: &schema.Schema{ Type: <%= tf_types[property.item_type_class] -%>, }, + <% elsif property.item_type.is_a?(Api::Type::Enum) -%> + Elem: &schema.Schema{ + Type: <%= tf_types[property.item_type.class] -%>, + ValidateFunc: validation.StringInSlice([]string{"<%= property.item_type.values.join '","' -%>"}, false), + }, <% else # array of basic types -%> Elem: &schema.Schema{ Type: <%= tf_types[property.item_type.class] -%>, @@ -126,7 +131,7 @@ <% if property.is_set -%> <% if !property.set_hash_func.nil? -%> Set: <%= property.set_hash_func -%>, - <% elsif property.item_type.is_a?(String) -%> + <% elsif property.item_type.is_a?(String) or property.item_type.is_a?(Api::Type::Enum) -%> Set: schema.HashString, <% else -%> // Default schema.HashSchema is used.