Class: Puppet::Provider::Auth0Rule::Auth0Rule
- Inherits:
-
ResourceApi::SimpleProvider
- Object
- ResourceApi::SimpleProvider
- Puppet::Provider::Auth0Rule::Auth0Rule
- Defined in:
- lib/puppet/provider/auth0_rule/auth0_rule.rb
Overview
Implementation for the auth0_rule type using the Resource API.
Instance Method Summary collapse
- #create(context, name, should) ⇒ Object
- #delete(context, name) ⇒ Object
- #get(context) ⇒ Object
- #update(context, name, should) ⇒ Object
Instance Method Details
#create(context, name, should) ⇒ Object
19 20 21 22 23 |
# File 'lib/puppet/provider/auth0_rule/auth0_rule.rb', line 19 def create(context, name, should) context.notice("Creating '#{name}' with #{should.inspect}") result = context.device.create_rule(name,should[:script],should[:order],should[:enabled],should[:run_stage]) Puppet.debug("Got response: #{result.inspect}") end |
#delete(context, name) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/puppet/provider/auth0_rule/auth0_rule.rb', line 37 def delete(context, name) context.notice("Deleting '#{name}'") id = get_rule_id_by_name(context,name) result = context.device.delete_rule(id) Puppet.debug("Got response: #{result.inspect}") end |
#get(context) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/puppet/provider/auth0_rule/auth0_rule.rb', line 6 def get(context) rules(context).map do |rule| { ensure: 'present', name: rule['name'], script: rule['script'], order: rule['order'], enabled: rule['enabled'], run_stage: rule['stage'], } end end |
#update(context, name, should) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/provider/auth0_rule/auth0_rule.rb', line 25 def update(context, name, should) context.notice("Updating '#{name}' with #{should.inspect}") id = get_rule_id_by_name(context,name) fields_to_update = { 'script' => should[:script], 'order' => should[:order], 'enabled' => should[:enabled], }.compact result = context.device.update_rule(id,fields_to_update) Puppet.debug("Got response: #{result.inspect}") end |