require 'json' require 'open-uri' require 'helix_web_services_client/open_model' class HelixWebServicesClient # Execute a Perforce command. # # First argument should always be the command, followed by command line # arguments. # # Expect to always have an array of hashes as output. # # Not all commands are allowed, since the command will be executed on the # web server. In general, if your command requires a client workspace, it # will likely fail, or be blocked. # # @return [OpenModel] wraps the output in an OpenModel instance def command(cmd, *args) params = arg_params(args) arr = execute_method_no_body(:get, hve_path("commands/#{URI.encode(cmd)}"), params) arr.map { |a| OpenModel.new(a) } if arr.is_a?(Array) end # Generic run command with and input body. # # The first argument is the general command, followed by the input data, # then followed by additional command line arguments. # # Expect the output to always be an array of hashes. # # Not all commands are allowed, since the command will be executed on the # web server. In general, if your command requires a client workspace, it # will likely fail, or be blocked. def command_with_input(cmd, input, *args) params = arg_params(args) params[:cmd] = cmd path = hve_path("commands/#{URI.encode(cmd)}") arr = execute_method_with_body(:post, path, params, input) arr.map { |a| OpenModel.new(a) } if arr.nil? == false and arr.is_a?(Array) end # Creates a hash and creates keys 'arg1', 'arg2', etc that points to # the values in the arg_values array. This is basically only used by # the run methods def arg_params(arg_values) params = {} arg_values.each_index { |ii| params["arg#{ii + 1}"] = arg_values[ii] } params end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services_client/lib/helix_web_services_client/commands.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services_client/lib/helix_web_services_client/commands.rb | |||||
#3 | 15240 | tjuricek |
Set api level via request path on all Helix Versioning Engine methods. This will allow migration of applications to different P4D versions. Our internal methods (like project API) should attempt to handle backward compatibility similarly. P4WEBAPI-118 |
||
#2 | 15208 | tjuricek |
Revise 'command' implementation, tests, and documentaiton. This includes a change from a command blacklist to a whitelist. See P4WEBAPI-21 |
||
#1 | 13808 | tjuricek | Finish converting most of the core p4d API into the new monolithic system. | ||
//guest/perforce_software/helix-web-services/main/p4_web_api/clients/ruby/p4_web_api_client/lib/p4_web_api_client/client/commands.rb | |||||
#1 | 13412 | tjuricek |
Initial version of the web-services mainline. This is a collection of several projects, that will likely often get released together, though many of them may not always be relevant. See the README for more information. |