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 (Google 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.

  • :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.

    • 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.

    ^

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

    The list of tags to add to a new topic.

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: