Module: Auth0::Api::V2::Rules
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/rules.rb
Overview
Methods to use the rules endpoints
Instance Method Summary collapse
-
#create_rule(name, script, order = nil, enabled = true, stage = 'login_success') ⇒ json
Creates a new rule according to the JSON object received in body.
-
#delete_rule(rule_id) ⇒ Object
Deletes a rule.
-
#rule(rule_id, fields: nil, include_fields: nil) ⇒ json
(also: #get_rule)
Retrieves a rule by its ID.
-
#rules(enabled: nil, fields: nil, include_fields: nil, stage: nil, page: nil, per_page: nil) ⇒ json
(also: #get_rules)
Retrieves a list of all rules.
-
#update_rule(rule_id, fields_to_update = {}) ⇒ json
Updates a rule.
Instance Method Details
#create_rule(name, script, order = nil, enabled = true, stage = 'login_success') ⇒ json
Creates a new rule according to the JSON object received in body. executes first. If no order is provided it will automatically be one greater than the current maximum. ‘user_registration’ or ‘user_blocked’.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/auth0/api/v2/rules.rb', line 65 def create_rule(name, script, order = nil, enabled = true, stage = 'login_success') raise Auth0::InvalidParameter, 'Must supply a valid name' if name.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid script' if script.to_s.empty? request_params = { name: name, enabled: enabled, script: script, order: order, stage: stage } post(rules_path, request_params) end |
#delete_rule(rule_id) ⇒ Object
Deletes a rule.
94 95 96 97 98 |
# File 'lib/auth0/api/v2/rules.rb', line 94 def delete_rule(rule_id) raise Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty? path = "#{rules_path}/#{rule_id}" delete(path) end |
#rule(rule_id, fields: nil, include_fields: nil) ⇒ json Also known as: get_rule
Retrieves a rule by its ID. Accepts a list of fields to include or exclude in the result.
42 43 44 45 46 47 48 49 50 |
# File 'lib/auth0/api/v2/rules.rb', line 42 def rule(rule_id, fields: nil, include_fields: nil) raise Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty? path = "#{rules_path}/#{rule_id}" request_params = { fields: fields, include_fields: include_fields } get(path, request_params) end |
#rules(enabled: nil, fields: nil, include_fields: nil, stage: nil, page: nil, per_page: nil) ⇒ json Also known as: get_rules
Retrieves a list of all rules. Accepts a list of fields to include or exclude. The enabled parameter can be specified to get enabled or disabled rules. The rule’s stage of executing could be set to the following values login_success, login_failure or pre_authorize
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/auth0/api/v2/rules.rb', line 21 def rules(enabled: nil, fields: nil, include_fields: nil, stage: nil, page: nil, per_page: nil) request_params = { enabled: enabled, fields: fields, include_fields: include_fields, stage: stage, page: page, per_page: per_page } get(rules_path, request_params) end |
#update_rule(rule_id, fields_to_update = {}) ⇒ json
Updates a rule.
84 85 86 87 88 89 |
# File 'lib/auth0/api/v2/rules.rb', line 84 def update_rule(rule_id, fields_to_update = {}) raise Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty? path = "#{rules_path}/#{rule_id}" patch(path, fields_to_update) end |