Skip to main content

rules

Creates, updates, deletes, gets or lists a rules resource.

Overview​

Namerules
TypeResource
Idoci.events.rules

Fields​

The following fields are returned by SELECT queries:

Succesfully retrieved rule.

NameDatatypeDescription
idstringThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) of this rule.
actionsobjectA list of Action objects associated with a rule. (x-example: {<br /> "actions": { }<br />}<br />)
compartmentIdstringThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs.
conditionstringA 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: &#123;&#125; 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\"
definedTagsobjectDefined 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: &#123;"Operations": &#123;"CostCenter": "42"&#125;&#125;
descriptionstringA string that describes the details of the rule. It does not have to be unique, and you can change it. Avoid entering confidential information.
displayNamestringA 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."
freeformTagsobjectFree-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: &#123;"Department": "Finance"&#125;
isEnabledbooleanWhether or not this rule is currently enabled. Example: true
lifecycleMessagestringA message generated by the Events service about the current state of this rule.
lifecycleStatestringThe current state of the rule. (CREATING, ACTIVE, INACTIVE, UPDATING, DELETING, DELETED, FAILED)
timeCreatedstring (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:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectruleId, regionopc-request-idRetrieves a rule.
listselectcompartmentId, regionlimit, page, lifecycleState, displayName, sortBy, sortOrder, opc-request-idLists rules for this compartment.<br />
createinsertregion, displayName, isEnabled, condition, actions, compartmentIdopc-retry-token, opc-request-idCreates a new rule.<br />
updateupdateruleId, regionif-match, opc-request-idUpdates a rule.<br />
deletedeleteruleId, regionif-match, opc-request-idDeletes a rule.
change_compartmentexecruleId, region, compartmentIdif-match, opc-request-id, opc-retry-tokenMoves 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.

NameDatatypeDescription
compartmentIdstringThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this rule belongs.
regionstringOCI 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)
ruleIdstringThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) of this rule.
displayNamestringA 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-matchstringFor 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.
lifecycleStatestringA filter to return only rules that match the lifecycle state in this parameter. Example: Creating
limitintegerThe maximum number of items to return. 1 is the minimum, 50 is the maximum. Default: 10
opc-request-idstringThe unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
opc-retry-tokenstringA 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).
pagestringFor 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).
sortBystringSpecifies the attribute with which to sort the rules. Default: timeCreated * TIME_CREATED: Sorts by timeCreated. * DISPLAY_NAME: Sorts by displayName. * ID: Sorts by id.
sortOrderstringSpecifies sort order. * ASC: Ascending sort order. * DESC: Descending sort order.

SELECT examples​

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 }}'
;

INSERT examples​

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
;

UPDATE examples​

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​

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​

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 }}"
}'
;