Skip to content

Commit

Permalink
Convert inboundServices to an enum. (#3820)
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson authored Aug 6, 2020
1 parent 1f18256 commit e9b56d3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
32 changes: 28 additions & 4 deletions products/appengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion templates/terraform/flatten_property_method.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down
7 changes: 6 additions & 1 deletion templates/terraform/schema_property.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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] -%>,
Expand All @@ -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.
Expand Down

0 comments on commit e9b56d3

Please sign in to comment.