rules
Creates, updates, deletes, gets or lists a rules resource.
Overview​
| Name | rules |
| Type | Resource |
| Id | oci.events.rules |
Fields​
The following fields are returned by SELECT queries:
- get
- list
Succesfully retrieved rule.
| Name | Datatype | Description |
|---|---|---|
id | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of this rule. |
actions | object | A list of Action objects associated with a rule. (x-example: {<br /> "actions": { }<br />}<br />) |
compartmentId | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs. |
condition | string | A filter that specifies the event that will trigger actions associated with this rule. A few important things to remember about filters: * Fields not mentioned in the condition are ignored. You can create a valid filter that matches all events with two curly brackets: {} For more examples, see [Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm). * For a condition with fields to match an event, the event must contain all the field names listed in the condition. Field names must appear in the condition with the same nesting structure used in the event. For a list of reference events, see [Services that Produce Events](/iaas/Content/Events/Reference/eventsproducers.htm). * Rules apply to events in the compartment in which you create them and any child compartments. This means that a condition specified by a rule only matches events emitted from resources in the compartment or any of its child compartments. * Wildcard matching is supported with the asterisk (*) character. For examples of wildcard matching, see [Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm) Example: \"eventType\": \"com.oraclecloud.databaseservice.autonomous.database.backup.end\" |
definedTags | object | Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm). Example: {"Operations": {"CostCenter": "42"}} |
description | string | A string that describes the details of the rule. It does not have to be unique, and you can change it. Avoid entering confidential information. |
displayName | string | A string that describes the rule. It does not have to be unique, and you can change it. Avoid entering confidential information. Example: "This rule sends a notification upon completion of DbaaS backup." |
freeformTags | object | Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross-compatibility only. For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm). Example: {"Department": "Finance"} |
isEnabled | boolean | Whether or not this rule is currently enabled. Example: true |
lifecycleMessage | string | A message generated by the Events service about the current state of this rule. |
lifecycleState | string | The current state of the rule. (CREATING, ACTIVE, INACTIVE, UPDATING, DELETING, DELETED, FAILED) |
timeCreated | string (date-time) | The time this rule was created, expressed in [RFC 3339](https:​//tools.ietf.org/html/rfc3339) timestamp format. Example: 2018-09-12T22:47:12.613Z |
The summary details of rules for Events. For more information, see<br />[Managing Rules for Events](/iaas/Content/Events/Task/managingrules.htm).<br />
| Name | Datatype | Description |
|---|---|---|
id | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of this rule. |
compartmentId | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs. |
condition | string | A filter that specifies the event that will trigger actions associated with this rule. A few important things to remember about filters: * Fields not mentioned in the condition are ignored. You can create a valid filter that matches all events with two curly brackets: {} For more examples, see [Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm). * For a condition with fields to match an event, the event must contain all the field names listed in the condition. Field names must appear in the condition with the same nesting structure used in the event. For a list of reference events, see [Services that Produce Events](/iaas/Content/Events/Reference/eventsproducers.htm). * Rules apply to events in the compartment in which you create them and any child compartments. This means that a condition specified by a rule only matches events emitted from resources in the compartment or any of its child compartments. * Wildcard matching is supported with the asterisk (*) character. For examples of wildcard matching, see [Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm) Example: \"eventType\": \"com.oraclecloud.databaseservice.autonomous.database.backup.end\" |
definedTags | object | Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm). Example: {"Operations": {"CostCenter": "42"}} |
description | string | A string that describes the details of the rule. It does not have to be unique, and you can change it. Avoid entering confidential information. |
displayName | string | A string that describes the rule. It does not have to be unique, and you can change it. Avoid entering confidential information. Example: "This rule sends a notification upon completion of DbaaS backup." |
freeformTags | object | Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross-compatibility only. For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm). Example: {"Department": "Finance"} |
isEnabled | boolean | Whether or not this rule is currently enabled. Example: true |
lifecycleState | string | (x-obmcs-enumref: #/definitions/Rule/lifecycleState) |
timeCreated | string (date-time) | The time this rule was created, expressed in [RFC 3339](https:​//tools.ietf.org/html/rfc3339) timestamp format. Example: 2018-09-12T22:47:12.613Z |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | ruleId, region | opc-request-id | Retrieves a rule. |
list | select | compartmentId, region | limit, page, lifecycleState, displayName, sortBy, sortOrder, opc-request-id | Lists rules for this compartment.<br /> |
create | insert | region, displayName, isEnabled, condition, actions, compartmentId | opc-retry-token, opc-request-id | Creates a new rule.<br /> |
update | update | ruleId, region | if-match, opc-request-id | Updates a rule.<br /> |
delete | delete | ruleId, region | if-match, opc-request-id | Deletes a rule. |
change_compartment | exec | ruleId, region, compartmentId | if-match, opc-request-id, opc-retry-token | Moves a rule into a different compartment within the same tenancy. For information about moving <br />resources between compartments, see [Moving Resources to a Different Compartment](/iaas/Content/Identity/Tasks/managingcompartments.htm#moveRes).<br /> |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
compartmentId | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs. |
region | string | OCI region identifier (e.g. us-ashburn-1, ap-sydney-1); resolves from OCI_REGION when not supplied in the query. (default: us-ashburn-1, x-stackQL-envVar: OCI_REGION) |
ruleId | string | The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of this rule. |
displayName | string | A filter to return only rules with descriptions that match the displayName string in this parameter. Example: "This rule sends a notification upon completion of DbaaS backup." |
if-match | string | For optimistic concurrency control. In the PUT or DELETE call for a resource, set the if-match parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value. |
lifecycleState | string | A filter to return only rules that match the lifecycle state in this parameter. Example: Creating |
limit | integer | The maximum number of items to return. 1 is the minimum, 50 is the maximum. Default: 10 |
opc-request-id | string | The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. |
opc-retry-token | string | A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected). |
page | string | For list pagination. The value of the opc-next-page response header from the previous "List" call. For important details about how pagination works, see [List Pagination](/iaas/Content/API/Concepts/usingapi.htm#nine). |
sortBy | string | Specifies the attribute with which to sort the rules. Default: timeCreated * TIME_CREATED: Sorts by timeCreated. * DISPLAY_NAME: Sorts by displayName. * ID: Sorts by id. |
sortOrder | string | Specifies sort order. * ASC: Ascending sort order. * DESC: Descending sort order. |
SELECT examples​
- get
- list
Retrieves a rule.
SELECT
id,
actions,
compartmentId,
condition,
definedTags,
description,
displayName,
freeformTags,
isEnabled,
lifecycleMessage,
lifecycleState,
timeCreated
FROM oci.events.rules
WHERE ruleId = '{{ ruleId }}' -- required
AND region = '{{ region }}' -- required
AND opc-request-id = '{{ opc-request-id }}'
;
Lists rules for this compartment.<br />
SELECT
id,
compartmentId,
condition,
definedTags,
description,
displayName,
freeformTags,
isEnabled,
lifecycleState,
timeCreated
FROM oci.events.rules
WHERE compartmentId = '{{ compartmentId }}' -- required
AND region = '{{ region }}' -- required
AND limit = '{{ limit }}'
AND page = '{{ page }}'
AND lifecycleState = '{{ lifecycleState }}'
AND displayName = '{{ displayName }}'
AND sortBy = '{{ sortBy }}'
AND sortOrder = '{{ sortOrder }}'
AND opc-request-id = '{{ opc-request-id }}'
;
INSERT examples​
- create
- Manifest
Creates a new rule.<br />
INSERT INTO oci.events.rules (
actions,
compartmentId,
condition,
definedTags,
description,
displayName,
freeformTags,
isEnabled,
region,
opc-retry-token,
opc-request-id
)
SELECT
'{{ actions }}' /* required */,
'{{ compartmentId }}' /* required */,
'{{ condition }}' /* required */,
'{{ definedTags }}',
'{{ description }}',
'{{ displayName }}' /* required */,
'{{ freeformTags }}',
{{ isEnabled }} /* required */,
'{{ region }}',
'{{ opc-retry-token }}',
'{{ opc-request-id }}'
RETURNING
id,
actions,
compartmentId,
condition,
definedTags,
description,
displayName,
freeformTags,
isEnabled,
lifecycleMessage,
lifecycleState,
timeCreated
;
# Description fields are for documentation purposes
- name: rules
props:
- name: region
value: "{{ region }}"
description: Required parameter for the rules resource.
- name: actions
description: |
A list of ActionDetails objects to create for a rule.
value:
actions:
- actionType: "{{ actionType }}"
description: "{{ description }}"
isEnabled: {{ isEnabled }}
- name: compartmentId
value: "{{ compartmentId }}"
description: |
The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs.
- name: condition
value: "{{ condition }}"
description: |
A filter that specifies the event that will trigger actions associated with this rule. A few
important things to remember about filters:
* Fields not mentioned in the condition are ignored. You can create a valid filter that matches
all events with two curly brackets: `{}`
For more examples, see
[Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm).
* For a condition with fields to match an event, the event must contain all the field names
listed in the condition. Field names must appear in the condition with the same nesting
structure used in the event.
For a list of reference events, see
[Services that Produce Events](/iaas/Content/Events/Reference/eventsproducers.htm).
* Rules apply to events in the compartment in which you create them and any child compartments.
This means that a condition specified by a rule only matches events emitted from resources in
the compartment or any of its child compartments.
* Wildcard matching is supported with the asterisk (*) character.
For examples of wildcard matching, see
[Matching Events with Filters](/iaas/Content/Events/Concepts/filterevents.htm)
Example: `"eventType": "com.oraclecloud.databaseservice.autonomous.database.backup.end"`
- name: definedTags
value: "{{ definedTags }}"
description: |
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm).
Example: `{"Operations": {"CostCenter": "42"}}`
- name: description
value: "{{ description }}"
description: |
A string that describes the details of the rule. It does not have to be unique, and you can change it. Avoid entering
confidential information.
- name: displayName
value: "{{ displayName }}"
description: |
A string that describes the rule. It does not have to be unique, and you can change it. Avoid entering
confidential information.
- name: freeformTags
value: "{{ freeformTags }}"
description: |
Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. Exists for cross-compatibility only.
For more information, see [Resource Tags](/iaas/Content/General/Concepts/resourcetags.htm).
Example: `{"Department": "Finance"}`
- name: isEnabled
value: {{ isEnabled }}
description: |
Whether or not this rule is currently enabled.
Example: `true`
default: true
- name: opc-retry-token
value: "{{ opc-retry-token }}"
description: A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).
description: A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).
- name: opc-request-id
value: "{{ opc-request-id }}"
description: The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
description: The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
UPDATE examples​
- update
Updates a rule.<br />
UPDATE oci.events.rules
SET
actions = '{{ actions }}',
condition = '{{ condition }}',
definedTags = '{{ definedTags }}',
description = '{{ description }}',
displayName = '{{ displayName }}',
freeformTags = '{{ freeformTags }}',
isEnabled = {{ isEnabled }}
WHERE
ruleId = '{{ ruleId }}' --required
AND region = '{{ region }}' --required
AND if-match = '{{ if-match}}'
AND opc-request-id = '{{ opc-request-id}}'
RETURNING
id,
actions,
compartmentId,
condition,
definedTags,
description,
displayName,
freeformTags,
isEnabled,
lifecycleMessage,
lifecycleState,
timeCreated;
DELETE examples​
- delete
Deletes a rule.
DELETE FROM oci.events.rules
WHERE ruleId = '{{ ruleId }}' --required
AND region = '{{ region }}' --required
AND if-match = '{{ if-match }}'
AND opc-request-id = '{{ opc-request-id }}'
;
Lifecycle Methods​
- change_compartment
Moves a rule into a different compartment within the same tenancy. For information about moving <br />resources between compartments, see [Moving Resources to a Different Compartment](/iaas/Content/Identity/Tasks/managingcompartments.htm#moveRes).<br />
EXEC oci.events.rules.change_compartment
@ruleId='{{ ruleId }}' --required,
@region='{{ region }}' --required,
@if-match='{{ if-match }}',
@opc-request-id='{{ opc-request-id }}',
@opc-retry-token='{{ opc-retry-token }}'
@@json=
'{
"compartmentId": "{{ compartmentId }}"
}'
;