aws.sns
Module aws.sns
API
Declarations
Definitions
![](https://bcentral-packageicons.azureedge.net/images/ballerinax_aws.sns_1.1.0.png)
ballerinax/aws.sns Ballerina library
Overview
The Ballerina AWS SNS provides the capability to manage topics and subscriptions in AWS SNS.
This module supports Amazon SNS REST API 2010-03-31
version.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create an AWS account
- Obtain tokens
Quickstart
To use the AWS SNS connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
Import the ballerinax/aws.sns
module into the Ballerina project.
import ballerinax/aws.sns;
Step 2: Create a new connector instance
You can now enter the credentials in the SNS client configuration and create the SNS client by passing the configuration as follows.
sns:LongTermCredentials longTermCredentials = { accessKey: "<ACCESS_KEY_ID>", secretKey: "<SECRET_ACCESS_KEY>" }; sns:ConnectionConfig config = { credentials:longTermCredentials, region: <REGION> }; sns:Client snsClient = check new (configuration);
Step 3: Invoke connector operation
-
You can create a topic in SNS as follows with
createTopic
method for a preferred topic name and the required set of attributes.sns:TopicAttribute attributes = { displayName : "Test" }; sns:CreateTopicResponse|error response = amazonSNSClient->createTopic(testTopic, attributes); if (response is sns:CreateTopicResponse) { log:printInfo("Created topic: " + response.toString()); }
-
Use
bal run
command to compile and run the Ballerina program.
Clients![](/images/permalink.svg)
aws.sns: Client![](/images/permalink.svg)
Ballerina Amazon SNS API connector provides the capability to access Amazon Simple Notification Service. This connector lets you to create and manage the sns topics and subscriptions.
Constructor![](/images/permalink.svg)
Initializes the connector.
init (ConnectionConfig configuration, ClientConfiguration httpClientConfig)
- configuration ConnectionConfig - Configuration for the connector
- httpClientConfig ClientConfiguration {} - HTTP Configuration
createTopic![](/images/permalink.svg)
function createTopic(string name, TopicAttributes? attributes, map<string>? tags) returns CreateTopicResponse|error
Create a topic.
Return Type
- CreateTopicResponse|error - Created topic ARN on success else an
error
subscribe![](/images/permalink.svg)
function subscribe(string topicArn, Protocol protocol, string? endpoint, boolean? returnSubscriptionArn, SubscriptionAttribute? attributes) returns SubscribeResponse|error
Subscribe to a topic.
Parameters
- topicArn string - The ARN of the topic you want to subscribe to
- protocol Protocol - The protocol that you want to use
- endpoint string? (default ()) - The endpoint that you want to receive notifications
- returnSubscriptionArn boolean? (default ()) -
- attributes SubscriptionAttribute? (default ()) - Subscription attributes
Return Type
- SubscribeResponse|error - Created subscription ARN on success else an
error
publish![](/images/permalink.svg)
function publish(string message, string? topicArn, string? targetArn, string? subject, string? phoneNumber, string? messageStructure, string? messageDeduplicationId, string? messageGroupId, MessageAttribute? messageAttributes) returns PublishResponse|error
Publish a message in a topic.
Parameters
- message string - The message content to publish
- topicArn string? (default ()) - The ARN of the topic
- targetArn string? (default ()) - The ARN of the target resource
- subject string? (default ()) - The subject of the message
- phoneNumber string? (default ()) - The phone number to send message
- messageStructure string? (default ()) - The message structure
- messageDeduplicationId string? (default ()) - The message dupilcation Id
- messageGroupId string? (default ()) - The message group Id
- messageAttributes MessageAttribute? (default ()) - The message attributes of type 'MessageAttribute'
Return Type
- PublishResponse|error - Result of message published on success else an
error
unsubscribe![](/images/permalink.svg)
function unsubscribe(string subscriptionArn) returns UnsubscribeResponse|error
Unsubscribe to a topic.
Parameters
- subscriptionArn string - The ARN of the subscription
Return Type
- UnsubscribeResponse|error - Result of unsubscription on success else an
error
deleteTopic![](/images/permalink.svg)
function deleteTopic(string topicArn) returns DeleteTopicResponse|error
Delete a topic.
Parameters
- topicArn string - The ARN of the topic
Return Type
- DeleteTopicResponse|error - Result of deleted topic on success else an
error
confirmSubscription![](/images/permalink.svg)
function confirmSubscription(string token, string topicArn, string? authenticateOnUnsubscribe) returns ConfirmedSubscriptionResponse|error
Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe action.
Parameters
- token string - The token to confirm subscription
- topicArn string - The ARN of the topic
- authenticateOnUnsubscribe string? (default ()) - Authenticate on unsubscription
Return Type
- ConfirmedSubscriptionResponse|error - Result of subscription confirmation on success else an
error
setTopicAttribute![](/images/permalink.svg)
function setTopicAttribute(string topicArn, string attributeName, string? attributeValue) returns error?
Add a topic attributes for a topic created.
Parameters
- topicArn string - Name of topic
- attributeName string - Name of a attribute
- attributeValue string? (default ()) - Value corresponding to that attribute
Return Type
- error? - Null on success else an
error
getTopicAttributes![](/images/permalink.svg)
function getTopicAttributes(string topicArn) returns GetTopicAttributesResponse|error
Get values of topic attributes for a topic.
Parameters
- topicArn string - ARN of a topic
Return Type
- GetTopicAttributesResponse|error - Array of TopicAttribute on success else an
error
setSMSAttributes![](/images/permalink.svg)
function setSMSAttributes(SmsAttributes attributes) returns error?
Add a SMS attributes for a SMS send.
Parameters
- attributes SmsAttributes - SMSAttributes record contain attribute information
Return Type
- error? - Null on success else an
error
getSMSAttributes![](/images/permalink.svg)
function getSMSAttributes(string[]? attributes) returns GetSMSAttributesResponse|error
Get values of SMS attributes.
Parameters
- attributes string[]? (default ()) - SMS attribute names
Return Type
- GetSMSAttributesResponse|error - Array of SmsAttribute on success else an
error
setSubscriptionAttribute![](/images/permalink.svg)
function setSubscriptionAttribute(string subscriptionArn, string attributeName, string? attributeValue) returns error?
Add a subscription attributes for a subscription created.
Parameters
- subscriptionArn string - Name of subscription
- attributeName string - Name of a attribute
- attributeValue string? (default ()) - Value corresponding to that attribute
Return Type
- error? - Null on success else an
error
getSubscriptionAttributes![](/images/permalink.svg)
function getSubscriptionAttributes(string subscriptionArn) returns GetSubscriptionAttributesResponse|error
Get values of subscription attributes for a subscription.
Parameters
- subscriptionArn string - ARN of a subscription
Return Type
- GetSubscriptionAttributesResponse|error - Array of SubscriptionAttribute on success else an
error
Enums![](/images/permalink.svg)
aws.sns: Protocol![](/images/permalink.svg)
Members
Records![](/images/permalink.svg)
aws.sns: AwsCredentials![](/images/permalink.svg)
AWS credentials.
Fields
- accessKeyId string - Access key Id
- secretAccessKey string - Security access key
aws.sns: AwsTemporaryCredentials![](/images/permalink.svg)
AWS temporary credentials.
Fields
- accessKeyId string - Access key Id
- secretAccessKey string - Security access key
- securityToken string - Security token
aws.sns: ConfirmedSubscriptionResponse![](/images/permalink.svg)
Fields
- confirmedSubscriptionResult ConfirmedSubscriptionResult -
- responseMetadata ResponseMetadata -
aws.sns: ConfirmedSubscriptionResult![](/images/permalink.svg)
Fields
- subscriptionArn string -
aws.sns: ConnectionConfig![](/images/permalink.svg)
Configuration provided for the client.
Fields
- credentials AwsCredentials|AwsTemporaryCredentials - Credentials to authenticate client
- region string(default "us-east-1") - Region of SNS resource
aws.sns: CreateTopicResponse![](/images/permalink.svg)
Fields
- createTopicResult CreateTopicResult -
- responseMetadata ResponseMetadata -
aws.sns: CreateTopicResult![](/images/permalink.svg)
Fields
- topicArn string -
aws.sns: DeleteTopicResponse![](/images/permalink.svg)
Fields
- responseMetadata ResponseMetadata -
aws.sns: ErrorDetail![](/images/permalink.svg)
Fields
- message string -
- cause error? -
aws.sns: GetSMSAttributesResponse![](/images/permalink.svg)
Fields
- getSMSAttributesResult GetSMSAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetSMSAttributesResult![](/images/permalink.svg)
Fields
- attributes json -
aws.sns: GetSubscriptionAttributesResponse![](/images/permalink.svg)
Fields
- getSubscriptionAttributesResult GetSubscriptionAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetSubscriptionAttributesResult![](/images/permalink.svg)
Fields
- attributes json -
aws.sns: GetTopicAttributesResponse![](/images/permalink.svg)
Fields
- getTopicAttributesResult GetTopicAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetTopicAttributesResult![](/images/permalink.svg)
Fields
- attributes json -
aws.sns: MessageAttribute![](/images/permalink.svg)
Fields
- key string? -
- value string? -
aws.sns: PublishResponse![](/images/permalink.svg)
Fields
- publishResult PublishResult -
- responseMetadata ResponseMetadata -
aws.sns: PublishResult![](/images/permalink.svg)
Fields
- messageId string -
aws.sns: ResponseMetadata![](/images/permalink.svg)
Fields
- requestId string -
aws.sns: SmsAttribute![](/images/permalink.svg)
Fields
- monthlySpendLimit string? -
- deliveryStatusIAMRole string? -
- deliveryStatusSuccessSamplingRate string? -
- defaultSenderID string? -
- defaultSMSType string? -
- usageReportS3Bucket string? -
aws.sns: SmsAttributeArray![](/images/permalink.svg)
Fields
- key string? -
- value string? -
aws.sns: SmsAttributes![](/images/permalink.svg)
Fields
- smsAttribute SmsAttributeArray[]? -
aws.sns: SubscribeResponse![](/images/permalink.svg)
Fields
- subscribeResult SubscribeResult -
- responseMetadata ResponseMetadata -
aws.sns: SubscribeResult![](/images/permalink.svg)
Fields
- subscriptionArn string -
aws.sns: SubscriptionAttribute![](/images/permalink.svg)
Fields
- deliveryPolicy string? -
- filterPolicy string? -
- rawMessageDelivery boolean? -
- redrivePolicy boolean? -
- subscriptionRoleArn string? -
aws.sns: SubscriptionAttributeArray![](/images/permalink.svg)
Fields
- key string? -
- value string? -
aws.sns: SubscriptionAttributes![](/images/permalink.svg)
Fields
- subscriptionAttribute SubscriptionAttributeArray[]? -
aws.sns: SubscriptionList![](/images/permalink.svg)
Fields
- owner string? -
- endpoint string? -
- protocol string? -
- subscriptionArn string? -
- topicArn string? -
aws.sns: Topic![](/images/permalink.svg)
Fields
- topicArn string -
- requestId string -
aws.sns: TopicAttribute![](/images/permalink.svg)
Fields
- deliveryPolicy string? -
- displayName string? -
- fifoTopic boolean? -
- contentBasedDeduplication boolean? -
- kmsMasterKeyId string? -
- policy string? -
aws.sns: TopicAttributeArray![](/images/permalink.svg)
Fields
- key string? -
- value string? -
aws.sns: TopicAttributes![](/images/permalink.svg)
Fields
- topicAttribute TopicAttributeArray[]? -
aws.sns: UnsubscribeResponse![](/images/permalink.svg)
Fields
- responseMetadata ResponseMetadata -
Errors![](/images/permalink.svg)
aws.sns: DataMappingError![](/images/permalink.svg)
aws.sns: FileReadFailed![](/images/permalink.svg)
aws.sns: GenerateRequestFailed![](/images/permalink.svg)
aws.sns: OperationError![](/images/permalink.svg)
aws.sns: ResponseHandleFailed![](/images/permalink.svg)
Import
import ballerinax/aws.sns;
Metadata
Released date: over 2 years ago
Version: 1.1.0
License: Apache-2.0
Compatibility
Platform: java11
Ballerina version: slbeta6
Pull count
Total: 403
Current verison: 1
Weekly downloads
Keywords
Communication/Notifications
Cost/Freemium
Vendor/Amazon
Contributors