lib/uaa/scim.rb in cf-uaa-lib-2.1.0 vs lib/uaa/scim.rb in cf-uaa-lib-3.0.0

- old
+ new

@@ -97,10 +97,11 @@ # @param [Hash] options can be # * +:symbolize_keys+, if true, returned hash keys are symbols. def initialize(target, auth_header, options = {}) @target, @auth_header = target, auth_header @key_style = options[:symbolize_keys] ? :downsym : :down + self.skip_ssl_validation = options[:skip_ssl_validation] self.http_proxy = options[:http_proxy] self.https_proxy = options[:https_proxy] end # Convenience method to get the naming attribute, e.g. userName for user, @@ -141,9 +142,27 @@ if info && info['meta'] && (etag = info['meta']['version']) hdrs.merge!('if-match' => etag) end reply = json_parse_reply(@key_style, *json_put(@target, "#{path}/#{URI.encode(id)}", info, hdrs)) + + # hide client endpoints that are not quite scim compatible + type == :client && !reply ? get(type, info['client_id']): reply + end + + # Modifies the contents of a SCIM object. + # @param (see #add) + # @return (see #add) + def patch(type, info) + path, info = type_info(type, :path), force_case(info) + ida = type == :client ? 'client_id' : 'id' + raise ArgumentError, "info must include #{ida}" unless id = info[ida] + hdrs = {'authorization' => @auth_header} + if info && info['meta'] && (etag = info['meta']['version']) + hdrs.merge!('if-match' => etag) + end + reply = json_parse_reply(@key_style, + *json_patch(@target, "#{path}/#{URI.encode(id)}", info, hdrs)) # hide client endpoints that are not quite scim compatible type == :client && !reply ? get(type, info['client_id']): reply end