Class: Puppet::Provider::Auth0Connection::Auth0Connection
- Inherits:
-
ResourceApi::SimpleProvider
- Object
- ResourceApi::SimpleProvider
- Puppet::Provider::Auth0Connection::Auth0Connection
- Defined in:
- lib/puppet/provider/auth0_connection/auth0_connection.rb
Overview
Implementation for the auth0_connection type using the Resource API.
Instance Method Summary collapse
- #canonicalize(context, resources) ⇒ Object
- #create(context, name, should) ⇒ Object
- #delete(context, name) ⇒ Object
- #get(context) ⇒ Object
- #update(context, name, should) ⇒ Object
Instance Method Details
#canonicalize(context, resources) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet/provider/auth0_connection/auth0_connection.rb', line 46 def canonicalize(context,resources) resources.each do |resource| remote_connection = get_connection_by_name(context,resource[:name]) if remote_connection if resource.delete(:keep_extra_clients) && resource[:clients] && remote_connection['enabled_clients'] remote_clients = remote_connection['enabled_clients'].map {|id| client_resource_identifier_by_id(context, id) } unmanaged_clients = (remote_clients - resource[:clients]) context.debug("Keeping extra clients for #{resource[:name]}: #{unmanaged_clients.inspect}") unless unmanaged_clients.empty? resource[:clients] += unmanaged_clients end if resource.delete(:keep_extra_options) && resource[:options] && remote_connection['options'] = remote_connection['options'].reject {|k,v| resource[:options].has_key?(k) } context.debug("Keeping extra options for #{resource[:name]}: #{.inspect}") unless .empty? resource[:options] = remote_connection['options'].merge(resource[:options]) end end resource[:clients] = resource[:clients].sort if resource[:clients].kind_of?(Array) end end |
#create(context, name, should) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/puppet/provider/auth0_connection/auth0_connection.rb', line 19 def create(context, name, should) context.notice("Creating '#{name}' with #{should.inspect}") context.device.create_connection({ name: should[:name], strategy: should[:strategy], options: should[:options], realms: should[:realms], enabled_clients: (should.has_key?(:clients) ? should[:clients].map {|cpri| client_id_by_resource_identifier(context,cpri) } : nil), }.compact) end |
#delete(context, name) ⇒ Object
40 41 42 43 44 |
# File 'lib/puppet/provider/auth0_connection/auth0_connection.rb', line 40 def delete(context, name) context.notice("Deleting '#{name}'") id = get_connection_id_by_name(context,name) context.device.delete_connection(id) end |
#get(context) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/puppet/provider/auth0_connection/auth0_connection.rb', line 6 def get(context) connections(context).map do |data| { ensure: 'present', name: data['name'], strategy: data['strategy'], options: data['options'], clients: (data['enabled_clients'] || []).map {|id| client_resource_identifier_by_id(context,id) }.sort, realms: (data['realms'] || []), }.compact end end |
#update(context, name, should) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet/provider/auth0_connection/auth0_connection.rb', line 30 def update(context, name, should) context.notice("Updating '#{name}' with #{should.inspect}") id = get_connection_id_by_name(context, name) context.device.update_connection(id, { options: should[:options], realms: should[:realms], enabled_clients: (should.has_key?(:clients) ? should[:clients].map {|cpri| client_id_by_resource_identifier(context,cpri) } : nil), }.compact) end |