Skip to content
Browse files

special handling for flat/unnamed link arguments, as in ConfigVarUpdate

  • Loading branch information...
1 parent 06795d7 commit 07b5a9ac3de0993880edf1d1f6c4d61b17a6589e @bgentry committed
Showing with 15 additions and 5 deletions.
  1. +3 −3 config_var.go
  2. +12 −2 gen/gen.rb
View
6 config_var.go
@@ -16,9 +16,9 @@ func (c *Client) ConfigVarInfo(appIdentity string) (map[string]string, error) {
// Update config-vars for app. You can update existing config-vars by setting
// them again, and remove by setting it to nil.
//
-// appIdentity is the unique identifier of the config-var's app.
-// configVarIdentity is the unique identifier of the ConfigVar.
+// appIdentity is the unique identifier of the config-var's app. options is the
+// hash of config changes – update values or delete by seting it to nil.
func (c *Client) ConfigVarUpdate(appIdentity string, options map[string]*string) (map[string]string, error) {
var configVarRes map[string]string
- return configVarRes, c.Patch(&configVarRes, "/apps/"+appIdentity+"/config-vars", nil)
+ return configVarRes, c.Patch(&configVarRes, "/apps/"+appIdentity+"/config-vars", options)
}
View
14 gen/gen.rb
@@ -62,9 +62,12 @@
<%- word_wrap(func_arg_comments.join(" "), line_width: 77).split("\n").each do |comment| %>
// <%= comment %>
<%- end %>
+ <%- flat_postval = link["schema"] && link["schema"]["additionalProperties"] == false %>
<%- required = (link["schema"] && link["schema"]["required"]) || [] %>
<%- optional = ((link["schema"] && link["schema"]["properties"]) || {}).keys - required %>
- <%- postval = if required.empty? && optional.empty? %>
+ <%- postval = if flat_postval %>
+ <%- "options" %>
+ <%- elsif required.empty? && optional.empty? %>
<%- "nil" %>
<%- elsif required.empty? %>
<%- "options" %>
@@ -358,12 +361,19 @@ def resolve_all_propdefs(propdef)
def func_arg_comments_from_model_and_link(definition, modelname, link)
args = []
+ flat_postval = link["schema"] && link["schema"]["additionalProperties"] == false
properties = (link["schema"] && link["schema"]["properties"]) || {}
required_keys = (link["schema"] && link["schema"]["required"]) || []
optional_keys = properties.keys - required_keys
if %w{update destroy self}.include?(link["rel"])
- args << "#{variablecase(modelname)}Identity is the unique identifier of the #{titlecase(modelname)}."
+ if flat_postval
+ # special case for ConfigVar update w/ flat param struct
+ desc = markdown_free(link["schema"]["description"])
+ args << "options is the #{desc}."
+ else
+ args << "#{variablecase(modelname)}Identity is the unique identifier of the #{titlecase(modelname)}."
+ end
end
if %w{create update}.include?(link["rel"])

0 comments on commit 07b5a9a

Please sign in to comment.
Something went wrong with that request. Please try again.