Class: Aws::RDS::EventSubscription

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-rds/event_subscription.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ EventSubscription #initialize(options = {}) ⇒ EventSubscription

Returns a new instance of EventSubscription.

Overloads:

  • #initialize(name, options = {}) ⇒ EventSubscription

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ EventSubscription

    Options Hash (options):

    • :name (required, String)
    • :client (Client)


22
23
24
25
26
27
28
# File 'lib/aws-sdk-rds/event_subscription.rb', line 22

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @name = extract_name(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
  @waiter_block_warned = false
end

Instance Method Details

#add_subscriber(options = {}) ⇒ EventSubscription

Examples:

Request syntax with placeholder values


eventsubscription = event_subscription.add_subscriber({
  source_identifier: "String", # required
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :source_identifier (required, String)

    The identifier of the event source to be added.

    Constraints:

    • If the source type is a DB instance, a ‘DBInstanceIdentifier` value must be supplied.

    • If the source type is a DB cluster, a ‘DBClusterIdentifier` value must be supplied.

    • If the source type is a DB parameter group, a ‘DBParameterGroupName` value must be supplied.

    • If the source type is a DB security group, a ‘DBSecurityGroupName` value must be supplied.

    • If the source type is a DB snapshot, a ‘DBSnapshotIdentifier` value must be supplied.

    • If the source type is a DB cluster snapshot, a ‘DBClusterSnapshotIdentifier` value must be supplied.

    • If the source type is an RDS Proxy, a ‘DBProxyName` value must be supplied.

Returns:



275
276
277
278
279
280
281
282
283
284
285
# File 'lib/aws-sdk-rds/event_subscription.rb', line 275

def add_subscriber(options = {})
  options = options.merge(subscription_name: @name)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.add_source_identifier_to_subscription(options)
  end
  EventSubscription.new(
    name: resp.data.event_subscription.cust_subscription_id,
    data: resp.data.event_subscription,
    client: @client
  )
end

#clientClient

Returns:



108
109
110
# File 'lib/aws-sdk-rds/event_subscription.rb', line 108

def client
  @client
end

#create(options = {}) ⇒ EventSubscription

Examples:

Request syntax with placeholder values


eventsubscription = event_subscription.create({
  sns_topic_arn: "String", # required
  source_type: "String",
  event_categories: ["String"],
  source_ids: ["String"],
  enabled: false,
  tags: [
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :sns_topic_arn (required, String)

    The Amazon Resource Name (ARN) of the SNS topic created for event notification. SNS automatically creates the ARN when you create a topic and subscribe to it.

    <note markdown=“1”> RDS doesn’t support FIFO (first in, first out) topics. For more information, see [Message ordering and deduplication (FIFO topics)] in the *Amazon Simple Notification Service Developer Guide*.

    </note>
    

    [1]: docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html

  • :source_type (String)

    The type of source that is generating the events. For example, if you want to be notified of events generated by a DB instance, you set this parameter to ‘db-instance`. For RDS Proxy events, specify `db-proxy`. If this value isn’t specified, all events are returned.

    Valid Values:‘ db-instance | db-cluster | db-parameter-group | db-security-group | db-snapshot | db-cluster-snapshot | db-proxy | zero-etl | custom-engine-version | blue-green-deployment `

  • :event_categories (Array<String>)

    A list of event categories for a particular source type (‘SourceType`) that you want to subscribe to. You can see a list of the categories for a given source type in the “Amazon RDS event categories and event messages” section of the [ *Amazon RDS User Guide* ][1] or the [ *Amazon Aurora User Guide* ][2]. You can also see this list by using the `DescribeEventCategories` operation.

    [1]: docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.Messages.html [2]: docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_Events.Messages.html

  • :source_ids (Array<String>)

    The list of identifiers of the event sources for which events are returned. If not specified, then all sources are included in the response. An identifier must begin with a letter and must contain only ASCII letters, digits, and hyphens. It can’t end with a hyphen or contain two consecutive hyphens.

    Constraints:

    • If ‘SourceIds` are supplied, `SourceType` must also be provided.

    • If the source type is a DB instance, a ‘DBInstanceIdentifier` value must be supplied.

    • If the source type is a DB cluster, a ‘DBClusterIdentifier` value must be supplied.

    • If the source type is a DB parameter group, a ‘DBParameterGroupName` value must be supplied.

    • If the source type is a DB security group, a ‘DBSecurityGroupName` value must be supplied.

    • If the source type is a DB snapshot, a ‘DBSnapshotIdentifier` value must be supplied.

    • If the source type is a DB cluster snapshot, a ‘DBClusterSnapshotIdentifier` value must be supplied.

    • If the source type is an RDS Proxy, a ‘DBProxyName` value must be supplied.

  • :enabled (Boolean)

    Specifies whether to activate the subscription. If the event notification subscription isn’t activated, the subscription is created but not active.

  • :tags (Array<Types::Tag>)

    A list of tags.

    For more information, see [Tagging Amazon RDS resources] in the *Amazon RDS User Guide* or [Tagging Amazon Aurora and Amazon RDS resources] in the *Amazon Aurora User Guide*.

    [1]: docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html [2]: docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_Tagging.html

Returns:



385
386
387
388
389
390
391
392
393
394
395
# File 'lib/aws-sdk-rds/event_subscription.rb', line 385

def create(options = {})
  options = options.merge(subscription_name: @name)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.create_event_subscription(options)
  end
  EventSubscription.new(
    name: resp.data.event_subscription.cust_subscription_id,
    data: resp.data.event_subscription,
    client: @client
  )
end

#customer_aws_idString

The Amazon Web Services customer account associated with the RDS event notification subscription.

Returns:

  • (String)


41
42
43
# File 'lib/aws-sdk-rds/event_subscription.rb', line 41

def customer_aws_id
  data[:customer_aws_id]
end

#dataTypes::EventSubscription

Returns the data for this Aws::RDS::EventSubscription. Calls Client#describe_event_subscriptions if #data_loaded? is ‘false`.

Returns:



130
131
132
133
# File 'lib/aws-sdk-rds/event_subscription.rb', line 130

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



138
139
140
# File 'lib/aws-sdk-rds/event_subscription.rb', line 138

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EventSubscription

Examples:

Request syntax with placeholder values


event_subscription.delete()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:



402
403
404
405
406
407
408
409
410
411
412
# File 'lib/aws-sdk-rds/event_subscription.rb', line 402

def delete(options = {})
  options = options.merge(subscription_name: @name)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.delete_event_subscription(options)
  end
  EventSubscription.new(
    name: resp.data.event_subscription.cust_subscription_id,
    data: resp.data.event_subscription,
    client: @client
  )
end

#enabledBoolean

Specifies whether the subscription is enabled. True indicates the subscription is enabled.

Returns:

  • (Boolean)


95
96
97
# File 'lib/aws-sdk-rds/event_subscription.rb', line 95

def enabled
  data[:enabled]
end

#event_categories_listArray<String>

A list of event categories for the RDS event notification subscription.

Returns:

  • (Array<String>)


88
89
90
# File 'lib/aws-sdk-rds/event_subscription.rb', line 88

def event_categories_list
  data[:event_categories_list]
end

#event_subscription_arnString

The Amazon Resource Name (ARN) for the event subscription.

Returns:

  • (String)


101
102
103
# File 'lib/aws-sdk-rds/event_subscription.rb', line 101

def event_subscription_arn
  data[:event_subscription_arn]
end

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


485
486
487
# File 'lib/aws-sdk-rds/event_subscription.rb', line 485

def identifiers
  { name: @name }
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::RDS::EventSubscription. Returns ‘self` making it possible to chain methods.

event_subscription.reload.data

Returns:

  • (self)


118
119
120
121
122
123
124
# File 'lib/aws-sdk-rds/event_subscription.rb', line 118

def load
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.describe_event_subscriptions(subscription_name: @name)
  end
  @data = resp.event_subscriptions_list[0]
  self
end

#modify(options = {}) ⇒ EventSubscription

Examples:

Request syntax with placeholder values


eventsubscription = event_subscription.modify({
  sns_topic_arn: "String",
  source_type: "String",
  event_categories: ["String"],
  enabled: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :sns_topic_arn (String)

    The Amazon Resource Name (ARN) of the SNS topic created for event notification. The ARN is created by Amazon SNS when you create a topic and subscribe to it.

  • :source_type (String)

    The type of source that is generating the events. For example, if you want to be notified of events generated by a DB instance, you would set this parameter to db-instance. For RDS Proxy events, specify ‘db-proxy`. If this value isn’t specified, all events are returned.

    Valid Values:‘ db-instance | db-cluster | db-parameter-group | db-security-group | db-snapshot | db-cluster-snapshot | db-proxy | zero-etl | custom-engine-version | blue-green-deployment `

  • :event_categories (Array<String>)

    A list of event categories for a source type (‘SourceType`) that you want to subscribe to. You can see a list of the categories for a given source type in [Events] in the *Amazon RDS User Guide* or by using the `DescribeEventCategories` operation.

    [1]: docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.html

  • :enabled (Boolean)

    Specifies whether to activate the subscription.

Returns:



448
449
450
451
452
453
454
455
456
457
458
# File 'lib/aws-sdk-rds/event_subscription.rb', line 448

def modify(options = {})
  options = options.merge(subscription_name: @name)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.modify_event_subscription(options)
  end
  EventSubscription.new(
    name: resp.data.event_subscription.cust_subscription_id,
    data: resp.data.event_subscription,
    client: @client
  )
end

#nameString Also known as: cust_subscription_id

Returns:

  • (String)


33
34
35
# File 'lib/aws-sdk-rds/event_subscription.rb', line 33

def name
  @name
end

#remove_subscriber(options = {}) ⇒ EventSubscription

Examples:

Request syntax with placeholder values


eventsubscription = event_subscription.remove_subscriber({
  source_identifier: "String", # required
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :source_identifier (required, String)

    The source identifier to be removed from the subscription, such as the **DB instance identifier** for a DB instance or the name of a security group.

Returns:



471
472
473
474
475
476
477
478
479
480
481
# File 'lib/aws-sdk-rds/event_subscription.rb', line 471

def remove_subscriber(options = {})
  options = options.merge(subscription_name: @name)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.remove_source_identifier_from_subscription(options)
  end
  EventSubscription.new(
    name: resp.data.event_subscription.cust_subscription_id,
    data: resp.data.event_subscription,
    client: @client
  )
end

#sns_topic_arnString

The topic ARN of the RDS event notification subscription.

Returns:

  • (String)


47
48
49
# File 'lib/aws-sdk-rds/event_subscription.rb', line 47

def sns_topic_arn
  data[:sns_topic_arn]
end

#source_ids_listArray<String>

A list of source IDs for the RDS event notification subscription.

Returns:

  • (Array<String>)


81
82
83
# File 'lib/aws-sdk-rds/event_subscription.rb', line 81

def source_ids_list
  data[:source_ids_list]
end

#source_typeString

The source type for the RDS event notification subscription.

Returns:

  • (String)


75
76
77
# File 'lib/aws-sdk-rds/event_subscription.rb', line 75

def source_type
  data[:source_type]
end

#statusString

The status of the RDS event notification subscription.

Constraints:

Can be one of the following: creating | modifying | deleting | active | no-permission | topic-not-exist

The status “no-permission” indicates that RDS no longer has permission to post to the SNS topic. The status “topic-not-exist” indicates that the topic was deleted after the subscription was created.

Returns:

  • (String)


63
64
65
# File 'lib/aws-sdk-rds/event_subscription.rb', line 63

def status
  data[:status]
end

#subscription_creation_timeString

The time the RDS event notification subscription was created.

Returns:

  • (String)


69
70
71
# File 'lib/aws-sdk-rds/event_subscription.rb', line 69

def subscription_creation_time
  data[:subscription_creation_time]
end

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::RDS::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged.

Waiter polls an API operation until a resource enters a desired state.

## Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

## Example

instance.wait_until(max_attempts:10, delay:5) do |instance|
  instance.state.name == 'running'
end

## Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

## Callbacks

You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

## Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/aws-sdk-rds/event_subscription.rb', line 222

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    Aws::Waiters::Waiter.new(options).wait({})
  end
end