diff --git a/sns/README.md b/sns/README.md index 26a78576..4ef43ec5 100644 --- a/sns/README.md +++ b/sns/README.md @@ -113,7 +113,8 @@ We support an array of consumers via the **consumers** field. This allows you to |---|:---:|---| | `protocol` | string | **Required.** The protocol that this endpoint receives messages by. Can be `http`, `https`, `email`, `email-json`, `sms`, `sqs`, `application`, `lambda` or `firehose` | | `endpoint` |[identifier](#identifier)| **Required.** The endpoint messages are delivered to. | -| `filterPolicy` | [filterPolicy](#filter-policy) | **Optional.** Only receive a subset of messages from the channel, determined by this policy. | +| `filterPolicy` | object | **Optional.** Only receive a subset of messages from the channel, determined by this policy. | +| `filterPolicyScope` | string | **Optional.** Determines whether the FilterPolicy applies to MessageAttributes (default) or MessageBody. | | `rawMessageDelivery` | boolean | **Required.** If *true* AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If *false* the SNS attributes are included in the body. | | `redrivePolicy` | [redrivePolicy](#redrive-policy) | **Optional.** Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue. | | `deliveryPolicy` | [deliveryPolicy](#delivery-policy) | **Optional.** Policy for retries to HTTP. The parameter is for that [SNS Subscription](https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html) and overrides any policy on the [SNS Topic](https://docs.aws.amazon.com/sns/latest/api/API_CreateTopic.html). | @@ -132,11 +133,6 @@ We support an array of consumers via the **consumers** field. This allows you to | `backoffFunction` | string, one of: arithmetic, exponential, geometric or linear | **Optional.** The algorithm for backoff between retries | | `maxReceivesPerSecond` | integer | **Optional.** The maximum number of deliveries per second, per subscription | -#### Filter Policy -|Field Name | Type | Description| -|---|:---:|---| -| `attributes` |Map(string, array or string or object) | **Required.** A map of a message attribute to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint | - #### Identifier |Field Name | Type | Description| |---|:---:|---| @@ -221,9 +217,8 @@ channels: name: user-signedup-queue # refers to a queue defined in this file, but not shown in this example rawMessageDelivery: true filterPolicy: - attributes: - reason: - anything-but: password-reset + reason: + anything-but: password-reset redrivePolicy: deadLetterQueue: name: user-signedup-queue-dlq # refers toa queue defined in this file, but not show in this example @@ -281,9 +276,9 @@ channels: endpoint: url: http://login.my.com/user/new filterPolicy: - attributes: - reason: - anything-but: password-reset + reason: + anything-but: password-reset + filterPolicyScope: MessageBody deliveryPolicy: minDelayTarget: 1 maxDelayTarget: 120 diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json index df59a327..25eb5935 100644 --- a/sns/json_schemas/operation.json +++ b/sns/json_schemas/operation.json @@ -95,7 +95,38 @@ "$ref": "#/definitions/identifier" }, "filterPolicy": { - "$ref": "#/definitions/filterPolicy" + "type": "object", + "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.", + "patternProperties": { + "^x-[\\w\\d\\.\\-\\_]+$": { + "$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension" + } + }, + "additionalProperties": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + }, + { + "type": "object" + } + ] + } + }, + "filterPolicyScope": { + "type": "string", + "description": "Determines whether the FilterPolicy applies to MessageAttributes or MessageBody.", + "enum": [ + "MessageAttributes", + "MessageBody" + ], + "default": "MessageAttributes" }, "rawMessageDelivery": { "type": "boolean", @@ -167,40 +198,6 @@ } } }, - "filterPolicy": { - "type": "object", - "description": "Only receive a subset of messages from the channel, determined by this policy.", - "patternProperties": { - "^x-[\\w\\d\\.\\-\\_]+$": { - "$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension" - } - }, - "properties": { - "attributes": { - "type": "object", - "description": "A map of a message attribute to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.", - "additionalProperties": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "string" - }, - { - "type": "object" - } - ] - } - } - }, - "required": [ - "attributes" - ] - }, "redrivePolicy": { "type": "object", "description": "Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue.", @@ -237,22 +234,21 @@ "name": "someQueue" }, "filterPolicy": { - "attributes": { - "store": [ - "asyncapi_corp" - ], - "event": [ - { - "anything-but": "order_cancelled" - } - ], - "customer_interests": [ - "rugby", - "football", - "baseball" - ] - } + "store": [ + "asyncapi_corp" + ], + "event": [ + { + "anything-but": "order_cancelled" + } + ], + "customer_interests": [ + "rugby", + "football", + "baseball" + ] }, + "filterPolicyScope": "MessageAttributes", "rawMessageDelivery": false, "redrivePolicy": { "deadLetterQueue": { @@ -274,4 +270,4 @@ ] } ] -} \ No newline at end of file +}