Class: ReactorSDK::Endpoints::Rules
- Inherits:
-
BaseEndpoint
- Object
- BaseEndpoint
- ReactorSDK::Endpoints::Rules
- Defined in:
- lib/reactor_sdk/endpoints/rules.rb
Instance Method Summary collapse
-
#comprehensive_upstream_chain(rule_or_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::ComprehensiveUpstreamChain
Resolves the rule across the ordered upstream chain and returns comprehensive review objects for the target and upstream entries.
-
#create(property_id:, name:, enabled: true) ⇒ ReactorSDK::Resources::Rule
Creates a new rule within a property.
-
#create_note(rule_id, text) ⇒ ReactorSDK::Resources::Note
Creates a note on a rule.
-
#delete(rule_id) ⇒ nil
Deletes a rule permanently.
-
#find(rule_id) ⇒ ReactorSDK::Resources::Rule
Retrieves a single rule by its Adobe ID.
-
#find_comprehensive(rule_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::ComprehensiveRule
Fetches the rule from a library-context review snapshot together with its associated rule components and normalized review payload.
-
#libraries(rule_id) ⇒ Array<ReactorSDK::Resources::Library>
Lists the libraries containing a rule.
-
#list_for_property(property_id) ⇒ Array<ReactorSDK::Resources::Rule>
Lists all rules for a given property.
-
#list_notes(rule_id) ⇒ Array<ReactorSDK::Resources::Note>
Lists notes attached directly to a rule.
-
#origin(rule_id) ⇒ ReactorSDK::Resources::Rule
Retrieves the origin revision head for a rule.
-
#property(rule_id) ⇒ ReactorSDK::Resources::Property
Retrieves the property that owns a rule.
-
#revise(rule_id) ⇒ ReactorSDK::Resources::Rule
Revises a rule so it can be added to a library.
-
#rule_component_notes(rule_id) ⇒ Array<ReactorSDK::Resources::RuleComponent>
Lists rule components associated with the rule’s component notes route.
-
#update(rule_id, attributes) ⇒ ReactorSDK::Resources::Rule
Updates an existing rule.
-
#upstream_chain(rule_or_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::UpstreamChain
Resolves the rule across the ordered upstream library chain.
Methods inherited from BaseEndpoint
Constructor Details
This class inherits a constructor from ReactorSDK::Endpoints::BaseEndpoint
Instance Method Details
#comprehensive_upstream_chain(rule_or_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::ComprehensiveUpstreamChain
Resolves the rule across the ordered upstream chain and returns comprehensive review objects for the target and upstream entries.
114 115 116 117 118 119 120 121 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 114 def comprehensive_upstream_chain(rule_or_id, library_id:, property_id:) libraries_endpoint.comprehensive_upstream_chain_for_resource( rule_or_id, library_id: library_id, property_id: property_id, resource_type: 'rules' ) end |
#create(property_id:, name:, enabled: true) ⇒ ReactorSDK::Resources::Rule
Creates a new rule within a property.
142 143 144 145 146 147 148 149 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 142 def create(property_id:, name:, enabled: true) create_resource( "/properties/#{property_id}/rules", 'rules', Resources::Rule, attributes: { name: name, enabled: enabled } ) end |
#create_note(rule_id, text) ⇒ ReactorSDK::Resources::Note
Creates a note on a rule.
205 206 207 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 205 def create_note(rule_id, text) create_note_for_path("/rules/#{rule_id}/notes", text) end |
#delete(rule_id) ⇒ nil
Deletes a rule permanently.
194 195 196 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 194 def delete(rule_id) delete_resource("/rules/#{rule_id}") end |
#find(rule_id) ⇒ ReactorSDK::Resources::Rule
Retrieves a single rule by its Adobe ID.
41 42 43 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 41 def find(rule_id) fetch_resource("/rules/#{rule_id}", Resources::Rule) end |
#find_comprehensive(rule_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::ComprehensiveRule
Fetches the rule from a library-context review snapshot together with its associated rule components and normalized review payload.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 94 def find_comprehensive(rule_id, library_id:, property_id:) snapshot = libraries_endpoint.find_snapshot(library_id, property_id: property_id) comprehensive = snapshot.comprehensive_resource(rule_id, resource_type: 'rules') unless comprehensive raise ReactorSDK::ResourceNotFoundError, "Rule #{rule_id} was not found in library #{library_id}" end comprehensive end |
#libraries(rule_id) ⇒ Array<ReactorSDK::Resources::Library>
Lists the libraries containing a rule.
61 62 63 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 61 def libraries(rule_id) list_resources("/rules/#{rule_id}/libraries", Resources::Library) end |
#list_for_property(property_id) ⇒ Array<ReactorSDK::Resources::Rule>
Lists all rules for a given property. Follows pagination automatically — returns all rules.
30 31 32 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 30 def list_for_property(property_id) list_resources("/properties/#{property_id}/rules", Resources::Rule) end |
#list_notes(rule_id) ⇒ Array<ReactorSDK::Resources::Note>
Lists notes attached directly to a rule.
215 216 217 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 215 def list_notes(rule_id) list_notes_for_path("/rules/#{rule_id}/notes") end |
#origin(rule_id) ⇒ ReactorSDK::Resources::Rule
Retrieves the origin revision head for a rule.
129 130 131 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 129 def origin(rule_id) fetch_resource("/rules/#{rule_id}/origin", Resources::Rule) end |
#property(rule_id) ⇒ ReactorSDK::Resources::Property
Retrieves the property that owns a rule.
51 52 53 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 51 def property(rule_id) fetch_resource("/rules/#{rule_id}/property", Resources::Property) end |
#revise(rule_id) ⇒ ReactorSDK::Resources::Rule
Revises a rule so it can be added to a library.
Adobe Launch requires every resource to be explicitly revised before it can be added to a library. A newly created or updated rule cannot be added to a library until revised.
Always call revise after create or update, before libraries.add_rules.
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 176 def revise(rule_id) update_resource( "/rules/#{rule_id}", rule_id, 'rules', Resources::Rule, attributes: {}, meta: { action: 'revise' } ) end |
#rule_component_notes(rule_id) ⇒ Array<ReactorSDK::Resources::RuleComponent>
Lists rule components associated with the rule’s component notes route.
225 226 227 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 225 def rule_component_notes(rule_id) list_resources("/rules/#{rule_id}/rule_component_notes", Resources::RuleComponent) end |
#update(rule_id, attributes) ⇒ ReactorSDK::Resources::Rule
Updates an existing rule.
159 160 161 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 159 def update(rule_id, attributes) update_resource("/rules/#{rule_id}", rule_id, 'rules', Resources::Rule, attributes: attributes) end |
#upstream_chain(rule_or_id, library_id:, property_id:) ⇒ ReactorSDK::Resources::UpstreamChain
Resolves the rule across the ordered upstream library chain.
This is a convenience wrapper around Libraries#upstream_chain_for_resource so rule workflows can stay resource-centric at the call site.
76 77 78 79 80 81 82 83 |
# File 'lib/reactor_sdk/endpoints/rules.rb', line 76 def upstream_chain(rule_or_id, library_id:, property_id:) libraries_endpoint.upstream_chain_for_resource( rule_or_id, library_id: library_id, property_id: property_id, resource_type: 'rules' ) end |