aws.sns
Module aws.sns
API
Declarations
Definitions
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:AwsCredentials longTermCredentials = { accessKeyId: "<ACCESS_KEY_ID>", secretAccessKey: "<SECRET_ACCESS_KEY>" }; sns:ConnectionConfig config = { credentials:longTermCredentials, region: "<REGION>" }; sns:Client snsClient = check new (config);
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 response = check amazonSNSClient->createTopic("testTopic", attributes); log:printInfo("Created topic: " + response.toString());
-
Use
bal run
command to compile and run the Ballerina program.
Clients
aws.sns: Client
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
Initializes the connector.
init (ConnectionConfig config)
- config ConnectionConfig -
createTopic
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
function subscribe(string topicArn, AwsProtocol 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 AwsProtocol - 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
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
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
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
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
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
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
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
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
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
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
aws.sns: AwsProtocol
Members
Records
aws.sns: AwsCredentials
AWS credentials.
Fields
- accessKeyId string - Access key Id
- secretAccessKey string - Security access key
aws.sns: AwsTemporaryCredentials
AWS temporary credentials.
Fields
- accessKeyId string - Access key Id
- secretAccessKey string - Security access key
- securityToken string - Security token
aws.sns: ConfirmedSubscriptionResponse
Fields
- confirmedSubscriptionResult ConfirmedSubscriptionResult -
- responseMetadata ResponseMetadata -
aws.sns: ConfirmedSubscriptionResult
Fields
- subscriptionArn string -
aws.sns: ConnectionConfig
Represents the AWS SNS Connection Configuration.
Fields
- Fields Included from *ConnectionConfig
- auth AuthConfig
- httpVersion HttpVersion
- http1Settings ClientHttp1Settings
- http2Settings ClientHttp2Settings
- timeout decimal
- forwarded string
- poolConfig PoolConfiguration
- cache CacheConfig
- compression Compression
- circuitBreaker CircuitBreakerConfig
- retryConfig RetryConfig
- responseLimits ResponseLimitConfigs
- secureSocket ClientSecureSocket
- proxy ProxyConfig
- validation boolean
- anydata...
- auth never? -
- credentials AwsCredentials|AwsTemporaryCredentials - Credentials to authenticate client
- region string(default "us-east-1") - Region of SNS resource
aws.sns: CreateTopicResponse
Fields
- createTopicResult CreateTopicResult -
- responseMetadata ResponseMetadata -
aws.sns: CreateTopicResult
Fields
- topicArn string -
aws.sns: DeleteTopicResponse
Fields
- responseMetadata ResponseMetadata -
aws.sns: GetSMSAttributesResponse
Fields
- getSMSAttributesResult GetSMSAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetSMSAttributesResult
Fields
- attributes json -
aws.sns: GetSubscriptionAttributesResponse
Fields
- getSubscriptionAttributesResult GetSubscriptionAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetSubscriptionAttributesResult
Fields
- attributes json -
aws.sns: GetTopicAttributesResponse
Fields
- getTopicAttributesResult GetTopicAttributesResult -
- responseMetadata ResponseMetadata -
aws.sns: GetTopicAttributesResult
Fields
- attributes json -
aws.sns: MessageAttribute
Fields
- key string? -
- value string? -
aws.sns: PublishResponse
Fields
- publishResult PublishResult -
- responseMetadata ResponseMetadata -
aws.sns: PublishResult
Fields
- messageId string -
aws.sns: ResponseMetadata
Fields
- requestId string -
aws.sns: SmsAttribute
Fields
- monthlySpendLimit string? -
- deliveryStatusIAMRole string? -
- deliveryStatusSuccessSamplingRate string? -
- defaultSenderID string? -
- defaultSMSType string? -
- usageReportS3Bucket string? -
aws.sns: SmsAttributeArray
Fields
- key string? -
- value string? -
aws.sns: SmsAttributes
Fields
- smsAttribute SmsAttributeArray[]? -
aws.sns: SubscribeResponse
Fields
- subscribeResult SubscribeResult -
- responseMetadata ResponseMetadata -
aws.sns: SubscribeResult
Fields
- subscriptionArn string -
aws.sns: SubscriptionAttribute
Fields
- deliveryPolicy string? -
- filterPolicy string? -
- rawMessageDelivery boolean? -
- redrivePolicy boolean? -
- subscriptionRoleArn string? -
aws.sns: TopicAttribute
Fields
- deliveryPolicy string? -
- displayName string? -
- fifoTopic boolean? -
- contentBasedDeduplication boolean? -
- kmsMasterKeyId string? -
- policy string? -
aws.sns: TopicAttributeArray
Fields
- key string? -
- value string? -
aws.sns: TopicAttributes
Fields
- topicAttribute TopicAttributeArray[]? -
aws.sns: UnsubscribeResponse
Fields
- responseMetadata ResponseMetadata -
Errors
aws.sns: DataMappingError
aws.sns: FileReadFailed
aws.sns: GenerateRequestFailed
aws.sns: OperationError
aws.sns: ResponseHandleFailed
Import
import ballerinax/aws.sns;
Metadata
Released date: over 1 year ago
Version: 2.1.0
License: Apache-2.0
Compatibility
Platform: java11
Ballerina version: 2201.4.1
Pull count
Total: 447
Current verison: 74
Weekly downloads
Keywords
Communication/Notifications
Cost/Freemium
Vendor/Amazon
Contributors