You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::SNS::Resource

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Overview

This class provides a resource oriented interface for Amazon SNS. To create a resource object:

resource = Aws::SNS::Resource.new

You can supply a client object with custom configuration that will be used for all resource operations. If you do not pass :client, a default client will be constructed.

client = Aws::SNS::Client.new(region: 'us-west-2')
resource = Aws::SNS::Resource.new(client: client)

Resource Resource Classes

Aws::SNS::Resource has the following resource classes:

Instance Attribute Summary

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Method Details

#create_platform_application(options = {}) ⇒ PlatformApplication

Examples:

Request syntax example with placeholder values


sns.create_platform_application({
  name: "String", # required
  platform: "String", # required
  attributes: { # required
    "String" => "String",
  },
})

Basic usage

platformapplication = sns.create_platform_application(options)
platformapplication.arn
#=> "platformapplication-arn"

Options Hash (options):

  • :name (required, String)

    Application names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, hyphens, and periods, and must be between 1 and 256 characters long.

  • :platform (required, String)

    The following platforms are supported: ADM (Amazon Device Messaging), APNS (Apple Push Notification Service), APNS_SANDBOX, and GCM (Firebase Cloud Messaging).

  • :attributes (required, Hash<String,String>)

    For a list of attributes, see SetPlatformApplicationAttributes

Returns:

See Also:

#create_topic(options = {}) ⇒ Topic

Examples:

Request syntax example with placeholder values


sns.create_topic({
  name: "topicName", # required
  attributes: {
    "attributeName" => "attributeValue",
  },
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
})

Basic usage

topic = sns.create_topic(options)
topic.arn
#=> "topic-arn"

Options Hash (options):

  • :name (required, String)

    The name of the topic you want to create.

    Constraints: Topic names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 256 characters long.

    For a FIFO (first-in-first-out) topic, the name must end with the .fifo suffix.

  • :attributes (Hash<String,String>)

    A map of attributes with their corresponding values.

    The following lists the names, descriptions, and values of the special request parameters that the CreateTopic action uses:

    • DeliveryPolicy – The policy that defines how Amazon SNS retries failed deliveries to HTTP/S endpoints.

    • DisplayName – The display name to use for a topic with SMS subscriptions.

    • FifoTopic – Set to true to create a FIFO topic.

    • Policy – The policy that defines who can access your topic. By default, only the topic owner can publish or subscribe to the topic.

    The following attribute applies only to server-side-encryption:

    • KmsMasterKeyId – The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK. For more information, see Key Terms. For more examples, see KeyId in the AWS Key Management Service API Reference.

    ^

    The following attributes apply only to FIFO topics:

    • FifoTopic – When this is set to true, a FIFO topic is created.

    • ContentBasedDeduplication – Enables content-based deduplication for FIFO topics.

      • By default, ContentBasedDeduplication is set to false. If you create a FIFO topic and this attribute is false, you must specify a value for the MessageDeduplicationId parameter for the Publish action.

      • When you set ContentBasedDeduplication to true, Amazon SNS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message).

        (Optional) To override the generated value, you can specify a value for the the MessageDeduplicationId parameter for the Publish action.

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

    The list of tags to add to a new topic.

    To be able to tag a topic on creation, you must have the sns:CreateTopic and sns:TagResource permissions.

Returns:

See Also:

#platform_application(arn) ⇒ PlatformApplication

Parameters:

Returns:

See Also:

#platform_applications(options = {}) ⇒ Collection<PlatformApplication>

Returns a Collection of PlatformApplication resources. No API requests are made until you call an enumerable method on the collection. Client#list_platform_applications will be called multiple times until every PlatformApplication has been yielded.

Examples:

Request syntax example with placeholder values


sns.platform_applications({
  next_token: "String",
})

Enumerating PlatformApplication resources.

sns.platform_applications.each do |platformapplication|
  # yields each platformapplication
end

Enumerating PlatformApplication resources with a limit.

sns.platform_applications.limit(10).each do |platformapplication|
  # yields at most 10 platform_applications
end

Options Hash (options):

  • :next_token (String)

    NextToken string is used when calling ListPlatformApplications action to retrieve additional records that are available after the first page results.

Returns:

See Also:

#platform_endpoint(arn) ⇒ PlatformEndpoint

Parameters:

Returns:

#subscription(arn) ⇒ Subscription

Parameters:

Returns:

See Also:

#subscriptions(options = {}) ⇒ Collection<Subscription>

Returns a Collection of Subscription resources. No API requests are made until you call an enumerable method on the collection. Client#list_subscriptions will be called multiple times until every Subscription has been yielded.

Examples:

Request syntax example with placeholder values


sns.subscriptions({
  next_token: "nextToken",
})

Enumerating Subscription resources.

sns.subscriptions.each do |subscription|
  # yields each subscription
end

Enumerating Subscription resources with a limit.

sns.subscriptions.limit(10).each do |subscription|
  # yields at most 10 subscriptions
end

Options Hash (options):

  • :next_token (String)

    Token returned by the previous ListSubscriptions request.

Returns:

See Also:

#topic(arn) ⇒ Topic

Parameters:

Returns:

See Also:

#topics(options = {}) ⇒ Collection<Topic>

Returns a Collection of Topic resources. No API requests are made until you call an enumerable method on the collection. Client#list_topics will be called multiple times until every Topic has been yielded.

Examples:

Request syntax example with placeholder values


sns.topics({
  next_token: "nextToken",
})

Enumerating Topic resources.

sns.topics.each do |topic|
  # yields each topic
end

Enumerating Topic resources with a limit.

sns.topics.limit(10).each do |topic|
  # yields at most 10 topics
end

Options Hash (options):

  • :next_token (String)

    Token returned by the previous ListTopics request.

Returns:

See Also: