Class: Fog::AWS::SNS::Real
- Inherits:
-
Object
- Object
- Fog::AWS::SNS::Real
- Includes:
- CredentialFetcher::ConnectionMethods
- Defined in:
- lib/fog/aws/sns.rb,
lib/fog/aws/requests/sns/publish.rb,
lib/fog/aws/requests/sns/subscribe.rb,
lib/fog/aws/requests/sns/list_topics.rb,
lib/fog/aws/requests/sns/unsubscribe.rb,
lib/fog/aws/requests/sns/create_topic.rb,
lib/fog/aws/requests/sns/delete_topic.rb,
lib/fog/aws/requests/sns/add_permission.rb,
lib/fog/aws/requests/sns/remove_permission.rb,
lib/fog/aws/requests/sns/list_subscriptions.rb,
lib/fog/aws/requests/sns/confirm_subscription.rb,
lib/fog/aws/requests/sns/get_topic_attributes.rb,
lib/fog/aws/requests/sns/set_topic_attributes.rb,
lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb
Instance Method Summary collapse
- #add_permission(options = {}) ⇒ Object
-
#confirm_subscription(arn, token, options = {}) ⇒ Object
Confirm a subscription.
-
#create_topic(name) ⇒ Object
Create a topic.
-
#delete_topic(arn) ⇒ Object
Delete a topic.
-
#get_topic_attributes(arn) ⇒ Object
Get attributes of a topic.
-
#initialize(options = {}) ⇒ Real
constructor
Initialize connection to SNS.
-
#list_subscriptions(options = {}) ⇒ Object
List subscriptions.
-
#list_subscriptions_by_topic(arn, options = {}) ⇒ Object
List subscriptions for a topic.
-
#list_topics(options = {}) ⇒ Object
List topics.
-
#publish(arn, message, options = {}) ⇒ Object
Send a message to a topic.
- #reload ⇒ Object
- #remove_permission(options = {}) ⇒ Object
-
#set_topic_attributes(arn, attribute_name, attribute_value) ⇒ Object
Set attributes of a topic.
-
#subscribe(arn, endpoint, protocol) ⇒ Object
Create a subscription.
-
#unsubscribe(arn) ⇒ Object
Delete a subscription.
Methods included from CredentialFetcher::ConnectionMethods
#refresh_credentials_if_expired
Constructor Details
#initialize(options = {}) ⇒ Real
Initialize connection to SNS
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
sns = SNS.new(
:aws_access_key_id => your_aws_access_key_id,
:aws_secret_access_key => your_aws_secret_access_key
)
Parameters
-
options<~Hash> - config arguments for connection. Defaults to {}.
Returns
-
SNS object with connection to AWS.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fog/aws/sns.rb', line 50 def initialize(={}) @use_iam_profile = [:use_iam_profile] @connection_options = [:connection_options] || {} @instrumentor = [:instrumentor] @instrumentor_name = [:instrumentor_name] || 'fog.aws.sns' [:region] ||= 'us-east-1' @region = [:region] @host = [:host] || "sns.#{[:region]}.amazonaws.com" @path = [:path] || '/' @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) setup_credentials() end |
Instance Method Details
#add_permission(options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/fog/aws/requests/sns/add_permission.rb', line 7 def ( = {}) request({ 'Action' => 'AddPermission', :parser => Fog::Parsers::AWS::SNS::AddPermission.new }.merge!()) end |
#confirm_subscription(arn, token, options = {}) ⇒ Object
Confirm a subscription
Parameters
-
arn<~String> - Arn of topic to confirm subscription to
-
token<~String> - Token sent to endpoint during subscribe action
-
options<~Hash>:
-
AuthenticateOnUnsubscribe<~Boolean> - whether or not unsubscription should be authenticated, defaults to false
-
See Also
docs.amazonwebservices.com/sns/latest/api/API_ConfirmSubscription.html
19 20 21 22 23 24 25 26 |
# File 'lib/fog/aws/requests/sns/confirm_subscription.rb', line 19 def confirm_subscription(arn, token, = {}) request({ 'Action' => 'ConfirmSubscription', 'Token' => token, 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::ConfirmSubscription.new }.merge!()) end |
#create_topic(name) ⇒ Object
Create a topic
Parameters
-
name<~String> - Name of topic to create
See Also
docs.amazonwebservices.com/sns/latest/api/API_CreateTopic.html
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/create_topic.rb', line 16 def create_topic(name) request({ 'Action' => 'CreateTopic', 'Name' => name, :parser => Fog::Parsers::AWS::SNS::CreateTopic.new }) end |
#delete_topic(arn) ⇒ Object
Delete a topic
Parameters
-
arn<~String> - The Arn of the topic to delete
See Also
docs.amazonwebservices.com/sns/latest/api/API_DeleteTopic.html
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/delete_topic.rb', line 16 def delete_topic(arn) request({ 'Action' => 'DeleteTopic', 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::DeleteTopic.new }) end |
#get_topic_attributes(arn) ⇒ Object
Get attributes of a topic
Parameters
-
arn<~Hash>: The Arn of the topic to get attributes for
See Also
docs.amazonwebservices.com/sns/latest/api/API_GetTopicAttributes.html
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/get_topic_attributes.rb', line 16 def get_topic_attributes(arn) request({ 'Action' => 'GetTopicAttributes', 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::GetTopicAttributes.new }) end |
#list_subscriptions(options = {}) ⇒ Object
List subscriptions
Parameters
-
options<~Hash>:
-
‘NextToken’<~String> - Token returned from previous request, used for pagination
-
See Also
docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptions.html
17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/list_subscriptions.rb', line 17 def list_subscriptions( = {}) request({ 'Action' => 'ListSubscriptions', :parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new }.merge!()) end |
#list_subscriptions_by_topic(arn, options = {}) ⇒ Object
List subscriptions for a topic
Parameters
-
arn<~String> - Arn of topic to list subscriptions for
-
options<~Hash>:
-
‘NextToken’<~String> - Token returned from previous request, used for pagination
-
See Also
docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptionsByTopic.html
18 19 20 21 22 23 24 |
# File 'lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb', line 18 def list_subscriptions_by_topic(arn, = {}) request({ 'Action' => 'ListSubscriptionsByTopic', 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new }.merge!()) end |
#list_topics(options = {}) ⇒ Object
List topics
Parameters
-
options<~Hash>:
-
‘NextToken’<~String> - Token returned from previous request, used for pagination
-
See Also
docs.amazonwebservices.com/sns/latest/api/API_ListTopics.html
17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/list_topics.rb', line 17 def list_topics( = {}) request({ 'Action' => 'ListTopics', :parser => Fog::Parsers::AWS::SNS::ListTopics.new }.merge!()) end |
#publish(arn, message, options = {}) ⇒ Object
Send a message to a topic
Parameters
-
arn<~String> - Arn of topic to send message to
-
message<~String> - Message to send to topic
-
options<~Hash>:
-
MessageStructure<~String> - message structure, in [‘json’]
-
Subject<~String> - value to use for subject when delivering by email
-
See Also
20 21 22 23 24 25 26 27 |
# File 'lib/fog/aws/requests/sns/publish.rb', line 20 def publish(arn, , = {}) request({ 'Action' => 'Publish', 'Message' => , 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Publish.new }.merge!()) end |
#reload ⇒ Object
69 70 71 |
# File 'lib/fog/aws/sns.rb', line 69 def reload @connection.reset end |
#remove_permission(options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/fog/aws/requests/sns/remove_permission.rb', line 7 def ( = {}) request({ 'Action' => 'RemovePermission', :parser => Fog::Parsers::AWS::SNS::RemovePermission.new }.merge!()) end |
#set_topic_attributes(arn, attribute_name, attribute_value) ⇒ Object
Set attributes of a topic
Parameters
-
arn<~Hash> - The Arn of the topic to get attributes for
-
attribute_name<~String> - Name of attribute to set, in [‘DisplayName’, ‘Policy’]
-
attribute_value<~String> - Value to set attribute to
See Also
docs.amazonwebservices.com/sns/latest/api/API_SetTopicAttributes.html
18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/aws/requests/sns/set_topic_attributes.rb', line 18 def set_topic_attributes(arn, attribute_name, attribute_value) request({ 'Action' => 'SetTopicAttributes', 'AttributeName' => attribute_name, 'AttributeValue' => attribute_value, 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::SetTopicAttributes.new }) end |
#subscribe(arn, endpoint, protocol) ⇒ Object
Create a subscription
Parameters
-
arn<~String> - Arn of topic to subscribe to
-
endpoint<~String> - Endpoint to notify
-
protocol<~String> - Protocol to notify endpoint with, in [‘email’, ‘email-json’, ‘http’, ‘https’, ‘sqs’]
See Also
docs.amazonwebservices.com/sns/latest/api/API_Subscribe.html
18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/aws/requests/sns/subscribe.rb', line 18 def subscribe(arn, endpoint, protocol) request({ 'Action' => 'Subscribe', 'Endpoint' => endpoint, 'Protocol' => protocol, 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Subscribe.new }) end |
#unsubscribe(arn) ⇒ Object
Delete a subscription
Parameters
-
arn<~String> - Arn of subscription to delete
See Also
docs.amazonwebservices.com/sns/latest/api/API_Unsubscribe.html
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/sns/unsubscribe.rb', line 16 def unsubscribe(arn) request({ 'Action' => 'Unsubscribe', 'SubscriptionArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Unsubscribe.new }) end |