require 'open-uri' require 'helix_web_services_client/open_model' class HelixWebServicesClient # Array of Label objects stored in the system. Not all fields will be # filled out (e.g., view). def labels arr = execute_method_no_body(:get, hve_path('labels')) arr.map { |a| OpenModel.new(a) } end # Returns the label instance indicated by the label name (or label object) def label(label) label = label.label if label.is_a?(OpenModel) obj = execute_method_no_body(:get, hve_path("labels/#{URI.encode(label)}")) OpenModel.new(obj) end # Creates a new label in the system. def create_label(label) label = OpenModel.new(label) unless label.is_a?(OpenModel) execute_method_with_body(:post, hve_path('labels'), label.marshal_dump) end # Updates the label specification. def update_label(label) label = OpenModel.new(label) unless label.is_a?(OpenModel) execute_method_with_body(:patch, hve_path("labels/#{URI.encode(label.label)}"), label.marshal_dump) end # Deletes the label specification in the system. def delete_label(label) label = label.label if label.is_a?(OpenModel) execute_method_no_body(:delete, hve_path("labels/#{URI.encode(label)}")) end end