lib/gzr/command.rb
def keys_to_keep(operation)
      o = @sdk.operations[operation]
      begin
        say_error "Operation #{operation} not found"
        return []
      end unless o

      parameters = o[:info][:parameters].select { |p| p[:in] == "body" && p[:schema] }

      say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters.length == 1
      schema_ref = parameters[0][:schema][:$ref].split(/\//)
      return @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
    end
##
# This method accepts the name of an sdk operation, then finds the parameter for that
# operation in the data structures from the swagger.json file. The parameter is a
# json object. Some of the attributes of the json object are read-only, and some
# are read-write. A few are write-only. The list of read-write and write-only attribute
# names are returned as an array. That array can be used to take the json document that
# describes an object and strip out the read-only values, creating a document that can
# be used to create or update an object.
#
# The pattern typically looks like this...
#
#   new_obj_hash = existing_obj_hash.select do |k,v|
#     keys_to_keep('create_new_obj').include? k
#   end
This method accepts the name of an sdk operation, then finds the parameter for that
operation in the data structures from the swagger.json file. The parameter is a
json object. Some of the attributes of the json object are read-only, and some
are read-write. A few are write-only. The list of read-write and write-only attribute
names are returned as an array. That array can be used to take the json document that
describes an object and strip out the read-only values, creating a document that can
be used to create or update an object.

The pattern typically looks like this


This method accepts the name of an sdk operation then finds the parameter for that operation in the data structures from the swagger . json file . The parameter is a json object . Some of the attributes of the json object are read - only and some are read - write . A few are write - only . The list of read - write and write - only attribute names are returned as an array . That array can be used to take the json document that describes an object and strip out the read - only values creating a document that can be used to create or update an object . The pattern typically looks like this
def keys_to_keep(operation)
      o = @sdk.operations[operation]
      begin
        say_error "Operation #{operation} not found"
        return []
      end unless o
      parameters = o[:info][:parameters].select { |p| p[:in] == "body" && p[:schema] }
      say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters.length == 1
      schema_ref = parameters[0][:schema][:$ref].split(/\//)
      return @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
    end
def keys_to_keep ( operation ) o = @sdk . operations [ operation ] begin say_error "Operation #{operation} not found" return [ ] end unless o parameters = o [ :info ] [ :parameters ] . select { | p | p [ :in ] == "body" && p [ :schema ] } say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters . length == 1 schema_ref = parameters [ 0 ] [ :schema ] [ :$ref ] . split ( / \/ / ) return @sdk . swagger [ schema_ref [ 1 ] . to_sym ] [ schema_ref [ 2 ] . to_sym ] [ :properties ] . reject { | k , v | v [ :readOnly ] } . keys end
This method accepts the name of an sdk operation, then finds the parameter for that
operation in the data structures from the swagger.json file.
This method accepts the name of an sdk operation then finds the parameter for that operation in the data structures from the swagger . json file .
operation