event-notifications-go-admin-sdk

module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: Apache-2.0

README

IBM Cloud Event Notifications Go Admin SDK 0.2.7

Go client library to interact with the various IBM Cloud Event Notifications APIs.

Table of Contents

Overview

The IBM Cloud Event Notifications Go SDK allows developers to programmatically interact with Event Notifications service in IBM cloud.

Service Name Package name

Event Notifications Service | eventnotificationsv1

Prerequisites

  • An IBM Cloud account.
  • An Event Notifications Instance
  • Go version 1.18 or above.

Installation

Install using the command.

go get -u github.com/IBM/event-notifications-go-admin-sdk
Go modules

If your application uses Go modules for dependency management (recommended), just add an import for each service that you will use in your application.
Here is an example:

import (
	"github.com/IBM/event-notifications-go-admin-sdk/eventnotificationsv1"
)

Next, run go build or go mod tidy to download and install the new dependencies and update your application's go.mod file.

In the example above, the eventnotificationsv1 part of the import path is the package name associated with the Example Service service. See the service table above to find the approprate package name for the services used by your application.

Initialize SDK

Initialize the sdk to connect with your Event Notifications service instance.

func initInstance() *eventnotificationsv1.EventNotificationsV1 {

    // IAM API key based authentication
	authenticator := &core.IamAuthenticator{
		ApiKey: <apikey>, // Event notifications service instance APIKey
	}

	// Set the options for the Event notification instance.
	options := &eventnotificationsv1.EventNotificationsV1Options{
		Authenticator: authenticator,
		URL:           "https://" + region + ".event-notifications.cloud.ibm.com/event-notifications",
	}
	eventNotificationsService, err := eventnotificationsv1.NewEventNotificationsV1(options)
	if err != nil {
		panic(err)
	}
	return eventNotificationsService

}

To configure service URL for Private Endpoint

If you enabled service endpoints in your account, you can send API requests over the IBM Cloud private network. In the initialisation, the base endpoint URLs of the IAM(authenticator) & Event Notification(service) should be modified to point to private endpoints.

  1. Setting client options programmatically
	authenticator := &core.IamAuthenticator{
		ApiKey: "<iam-api-key>",
		URL: "https://private.iam.cloud.ibm.com",
	}

	options := &eventnotificationsv1.EventNotificationsV1Options{
		Authenticator: authenticator,
		URL:           "https://private." + region + ".event-notifications.cloud.ibm.com/event-notifications",
	}
  1. Using external configuration properties
   EVENT_NOTIFICATIONS_AUTH_URL = https://private.iam.cloud.ibm.com/identity/token
  • region : Region of the Event Notifications Instance

Using the SDK

SDK Methods to consume

Source

Create Source
createSourcesOptions := eventNotificationsService.NewCreateSourcesOptions(
	    <instance-id>, // Event notifications service instance GUID
		<source-name>,
		<source-description>,
	)
createSourcesOptions.SetEnabled(false)

sourceResponse, response, err := eventNotificationsService.CreateSources(createSourcesOptions)
List Sources
listSourcesOptions := eventNotificationsService.NewListSourcesOptions(
	<instance-id>, // Event notifications service instance GUID
)

sourceList, response, err := eventNotificationsService.ListSource(listSourcesOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(sourceList, "", "  ")
fmt.Println(string(b))
Get Sources
getSourceOptions := eventNotificationsService.NewGetSourceOptions(
	<instance-id>, // Event notifications service instance GUID
	<source-id>,   // Event notifications service instance Source ID
)

source, response, err := eventNotificationsService.GetSource(getSourceOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(source, "", "  ")
fmt.Println(string(b))
Update Source
updateSourceOptions := eventNotificationsService.NewUpdateSourceOptions(
		<instance-id>, // Event notifications service instance GUID
	    <source-id>,   // Event notifications service instance Source ID
	)
updateSourceOptions.SetName(*core.StringPtr(<source-updated-name>))
updateSourceOptions.SetDescription(*core.StringPtr(<source-updated-description>))
updateSourceOptions.SetEnabled(true)

source, response, err := eventNotificationsService.UpdateSource(updateSourceOptions)
Delete Source
deleteSourceOptions := eventNotificationsService.NewDeleteSourceOptions(
	<instance-id>, // Event notifications service instance GUID
	<source-id>,   // Event notifications service instance Source ID
)

response, err := eventNotificationsService.DeleteSource(deleteSourceOptions)

Topics

Create Topic
rulesModel := &eventnotificationsv1.Rules{
	Enabled:            core.BoolPtr(false),
	EventTypeFilter:    core.StringPtr("$.notification_event_info.event_type == 'cert_manager'"), // Add your event type filter here.
	NotificationFilter: core.StringPtr("$.notification.findings[0].severity == 'MODERATE'"), // Add your notification filter here.
}

topicUpdateSourcesItemModel := &eventnotificationsv1.TopicUpdateSourcesItem{
	ID:    core.StringPtr(<source-id>),
	Rules: []eventnotificationsv1.Rules{*rulesModel},
}

createTopicOptions := &eventnotificationsv1.CreateTopicOptions{
	InstanceID:  core.StringPtr(<instance-id>),
	Name:        core.StringPtr(<topic-name>]),
	Description: core.StringPtr(<topic-description>),
	Sources:     []eventnotificationsv1.TopicUpdateSourcesItem{*topicUpdateSourcesItemModel},
}

topic, response, err := eventNotificationsService.CreateTopic(createTopicOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(topic, "", "  ")
fmt.Println(string(b))
List Topics
listTopicsOptions := eventNotificationsService.NewListTopicsOptions(
	<instance-id>,
)

topicList, response, err := eventNotificationsService.ListTopic(listTopicsOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(topicList, "", "  ")
fmt.Println(string(b))
Get Topic
getTopicOptions := eventNotificationsService.NewGetTopicOptions(
	<instance-id>, // Event notifications service instance GUID
	<topic-id>, // Event notifications service instance Topic ID
)

topic, response, err := eventNotificationsService.GetTopic(getTopicOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(topic, "", "  ")
fmt.Println(string(b))
Update Topic

rulesModel := &eventnotificationsv1.Rules{
	Enabled:            core.BoolPtr(true),
	EventTypeFilter:    core.StringPtr("$.notification_event_info.event_type == 'core_cert_manager'"), // Add your event type filter here.
	NotificationFilter: core.StringPtr("$.notification.findings[0].severity == 'SEVERE'"), // Add your notification filter here.
}

topicUpdateSourcesItemModel := &eventnotificationsv1.TopicUpdateSourcesItem{
	ID:    core.StringPtr(<source-id>),  // Event notifications service instance Source ID
	Rules: []eventnotificationsv1.Rules{*rulesModel},
}

replaceTopicOptions := &eventnotificationsv1.ReplaceTopicOptions{
	InstanceID:  core.StringPtr(<instance-id>), // Event notifications service instance GUID
	ID:          core.StringPtr(<topic-id>),    // Event notifications service instance Topic ID
	Name:        core.StringPtr(<topic-update-name>),  // Event notifications service instance Topic Name
	Description: core.StringPtr(<topic-update-description>), // Event notifications service instance Topic description
	Sources:     []eventnotificationsv1.TopicUpdateSourcesItem{*topicUpdateSourcesItemModel},
}

topic, response, err := eventNotificationsInstance.ReplaceTopic(replaceTopicOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(topic, "", "  ")
fmt.Println(string(b))

Delete Topic
deleteTopicOptions := eventNotificationsService.NewDeleteTopicOptions(
	<instance-id>,
	<topic-id>,
)

response, err := eventNotificationsService.DeleteTopic(deleteTopicOptions)

if err != nil {
	panic(err)
}

Destinations

Create Destination
createDestinationOptions := eventNotificationsService.NewCreateDestinationOptions(
	<instance-id>,
	<destination-name>,
	<destination-type>,
)
destinationConfigParamsModel := &eventnotificationsv1.DestinationConfigParamsWebhookDestinationConfig{
	URL:              core.StringPtr(<destination-config-url>),
	Verb:             core.StringPtr(<destination-config-verb>),
	CustomHeaders:    make(map[string]string),
	SensitiveHeaders: []string{<header-key>},
}
destinationConfigModel := &eventnotificationsv1.DestinationConfig{
	Params: destinationConfigParamsModel,
}
createDestinationOptions.SetConfig(destinationConfigModel)

destination, response, err := eventNotificationsService.CreateDestination(createDestinationOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(destination, "", "  ")
fmt.Println(string(b))

Among the supported destinations, if you need to create Push Notification destinations, you have the additional option of choosing a destination of production type or pre-production type. Set pre_prod boolean parameter to true to configure destination as pre-production destination else set the value as false. Supported destinations are Android, iOS, Chrome, Firefox and Safari.

List Destinations
listDestinationsOptions := eventNotificationsService.NewListDestinationsOptions(
	<instance-id>,
)

destinationList, response, err := eventNotificationsService.ListDestinations(listDestinationsOptions)
if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(destinationList, "", "  ")
fmt.Println(string(b))
Get Destination
getDestinationOptions := eventNotificationsService.NewGetDestinationOptions(
	<instance-id>,       // Event notifications service instance GUID
	<destination-id>,    // Event notifications service instance Destination ID
)

destination, response, err := eventNotificationsService.GetDestination(getDestinationOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(destination, "", "  ")
fmt.Println(string(b))
Update Destination
destinationConfigParamsModel := &eventnotificationsv1.DestinationConfigParamsWebhookDestinationConfig{
	URL:              core.StringPtr(<destination-config-update-url>),
	Verb:             core.StringPtr(<destination-config-update-verb>),
	CustomHeaders:    make(map[string]string),
	SensitiveHeaders: []string{<header-key>},
}

destinationConfigModel := &eventnotificationsv1.DestinationConfig{
	Params: destinationConfigParamsModel,
}

updateDestinationOptions := eventNotificationsService.NewUpdateDestinationOptions(
	<instance-id>,      // Event notifications service instance GUID
	<destination-id>,   // Event notifications service instance Destination ID
)

updateDestinationOptions.SetName(<destination-update-name>)
updateDestinationOptions.SetDescription(<destination-update-description>)
updateDestinationOptions.SetConfig(destinationConfigModel)

destination, response, err := eventNotificationsService.UpdateDestination(updateDestinationOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(destination, "", "  ")
fmt.Println(string(b))

Delete Destination
deleteDestinationOptions := eventNotificationsService.NewDeleteDestinationOptions(
	<instance-id>,		// Event notifications service instance GUID
	<destination-id>,	// Event notifications service instance Destination ID
)

response, err := eventNotificationsService.DeleteDestination(deleteDestinationOptions)

if err != nil {
	panic(err)
}
Custom Domain Name Verification

After creation of the custom email destination with your domain name, make sure its validated for the right ownership. This can be done with SPF and DKIM verification.

  • Sender Policy Framework (SPF), which is used to authenticate the sender of an email. SPF specifies the mail servers that are allowed to send email for your domain.
  • DomainKeys Identified Mail (DKIM), which allows an organization to take responsibility for transmitting a message by signing it. DKIM allows the receiver to check the email that claimed to have come from a specific domain, is authorized by the owner of that domain.
customSpfDkimUpdateDestinationOptions := &eventnotificationsv1.UpdateVerifyDestinationOptions{
	InstanceID: core.StringPtr(<instance-id>),       // Event notifications service instance GUID
	ID:         core.StringPtr(<destination-id>),	 // Event notifications service instance Destination ID
	Type:       core.StringPtr(<verification-type>), // verification type spf/dkim
}

result, response, err := eventNotificationsService.UpdateVerifyDestination(customSpfUpdateDestinationOptions)

if err != nil {
	panic(err)
}

Templates

Template is a pre-defined layout, that may include content like images, text and dynamic content based on event. Rather than creating a new content from scratch each time, you can use a template as a base and configure them in subscription. supports the following templates:

  • Custom Email notification
  • Custom Email invitation
Create Template
templConfig := &eventnotificationsv1.TemplateConfig{
	Body:    core.StringPtr("<!DOCTYPE html><html><head><title>IBM Event Notifications</title></head><body><p>Hello! Invitation template</p><table><tr><td>Hello invitation link:{{ ibmen_invitation }} </td></tr></table></body></html>"),
	Subject: core.StringPtr("Hi this is invitation for invitation message"),
}

createTemplateOptions := &eventnotificationsv1.CreateTemplateOptions{
	InstanceID:  core.StringPtr(<instance-id>),
	Name:        core.StringPtr(<name>),
	Type:        core.StringPtr(<template-type>),
	Description: core.StringPtr(<description>),
	Params:      templConfig,
}

templateResponse, response, err := eventNotificationsService.CreateTemplate(createTemplateOptions)
List Templates
listTemplatesOptions := eventNotificationsService.NewListTemplatesOptions(
	InstanceID: core.StringPtr(<instance-id>),
)

templatesList, response, err := eventNotificationsService.ListTemplates(listTemplatesOptions)
Get Template
getTemplateOptions := &eventnotificationsv1.GetTemplateOptions{
	InstanceID: core.StringPtr(<instance-id>),
	ID:         core.StringPtr(<template-id>),
}

template, response, err := eventNotificationsService.GetTemplate(getTemplateOptions)
Update Template
templateConfig := &eventnotificationsv1.TemplateConfig{
	Body:    core.StringPtr("<!DOCTYPE html><html><head><title>IBM Event Notifications</title></head><body><p>Hello! Invitation template</p><table><tr><td>Hello invitation link:{{ ibmen_invitation }} </td></tr></table></body></html>"),
	Subject: core.StringPtr("Hi this is invitation for invitation message"),
}

updateTemplateOptions := &eventnotificationsv1.UpdateTemplateOptions{
	InstanceID:  core.StringPtr(<instance-id>),
	ID:          core.StringPtr(<template-id>),
	Name:        core.StringPtr(<name>),
	Type:        core.StringPtr(<template-type>),
	Description: core.StringPtr(<description>),
	Params:      templateConfig,
}

templateResponse, response, err := eventNotificationsService.UpdateTemplate(updateTemplateOptions)
Delete Template
deleteTemplateOptions := &eventnotificationsv1.DeleteTemplateOptions{
	InstanceID: core.StringPtr(<instance-id>),
	ID:         core.StringPtr(<template-id>),
}

response, err := eventNotificationsService.DeleteTemplate(deleteTemplateOptions)

Push Destination APIs

Create Destination tag subscription
createTagsSubscriptionOptions := eventNotificationsService.NewCreateTagsSubscriptionOptions(
	<instance-id>,		// Event notifications service instance GUID
	<destination-id>,	// Event notifications service instance Destination ID
	<device-id>,		// Event notifications service device ID
	<tag-name>,			// Event notifications service tag name
)

destinationTagsSubscriptionResponse, response, err := eventNotificationsService.CreateTagsSubscription(createTagsSubscriptionOptions)

if err != nil {
	panic(err)
}
List Destination tag subscription
listTagsSubscriptionOptions := eventNotificationsService.NewListTagsSubscriptionOptions(
	<instance-id>,		// Event notifications service instance GUID
	<destination-id>,	// Event notifications service instance Destination ID
)

tagsSubscriptionList, response, err := eventNotificationsService.ListTagsSubscription(listTagsSubscriptionOptions)

if err != nil {
	panic(err)
}
Delete Destination device tag subscription
deleteTagsSubscriptionOptions := eventNotificationsService.NewDeleteTagsSubscriptionOptions(
	<instance-id>,		// Event notifications service instance GUID
	<destination-id>,	// Event notifications service instance Destination ID
)

deleteTagsSubscriptionOptions.SetDeviceID(<device-id>)
deleteTagsSubscriptionOptions.SetTagName(<tag-name>)
response, err := eventNotificationsService.DeleteTagsSubscription(deleteTagsSubscriptionOptions)
if err != nil {
	panic(err)
}

Subscriptions

Create Subscription
`While Creating Subscription use any of one option from webhook or email`

subscriptionCreateAttributesModel := &eventnotificationsv1.SubscriptionCreateAttributes{
	SigningEnabled: core.BoolPtr(false),
}

createSubscriptionOptions := eventNotificationsService.NewCreateSubscriptionOptions(
	<instance-id>,	// Event notifications service instance GUID
	<subscription-name>,
	<destination-id>, // Event notifications service instance Destination ID
	<topic-id>,  // Event notifications service instance Topic ID
	subscriptionCreateAttributesModel,
)

createSubscriptionOptions.SetDescription(<subscription-description>)

subscription, response, err := eventNotificationsService.CreateSubscription(createSubscriptionOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(subscription, "", "  ")
fmt.Println(string(b))
List Subscriptions
listSubscriptionsOptions := eventNotificationsService.NewListSubscriptionsOptions(
	<instance-id>,	// Event notifications service instance GUID
)

subscriptionList, response, err := eventNotificationsService.ListSubscriptions(listSubscriptionsOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(subscriptionList, "", "  ")
fmt.Println(string(b))
Get Subscription
getSubscriptionOptions := eventNotificationsService.NewGetSubscriptionOptions(
	<instance-id>,	// Event notifications service instance GUID
	<subscription-id>,	// Event notifications service instance Subscription ID
)

subscription, response, err := eventNotificationsService.GetSubscription(getSubscriptionOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(subscription, "", "  ")
fmt.Println(string(b))
Update Subscription

updateSubscriptionOptions := eventNotificationsService.NewUpdateSubscriptionOptions(
	<instance-id>,	// Event notifications service instance GUID
	<subscription-id>,	// Event notifications service instance Subscription ID
)

subscriptionUpdateAttributesModel := &eventnotificationsv1.SubscriptionUpdateAttributesWebhookAttributes{
	SigningEnabled: core.BoolPtr(true),
}

updateSubscriptionOptions.SetAttributes(subscriptionUpdateAttributesModel)
updateSubscriptionOptions.SetDescription(<subscription-update-description>)
updateSubscriptionOptions.SetName(<subscription-update-name>)

subscription, response, err := eventNotificationsService.UpdateSubscription(updateSubscriptionOptions)

if err != nil {
	panic(err)
}

b, _ := json.MarshalIndent(subscription, "", "  ")
fmt.Println(string(b))

Delete Subscription
deleteSubscriptionOptions := eventNotificationsService.NewDeleteSubscriptionOptions(
	<instance-id>,	// Event notifications service instance GUID
	<subscription-id>,	// Event notifications service instance Subscriptions ID
)

response, err := eventNotificationsService.DeleteSubscription(deleteSubscriptionOptions)

if err != nil {
	panic(err)
}

Integration

Get Integration
getIntegrationOptions := &eventnotificationsv1.GetIntegrationOptions{
	InstanceID: core.StringPtr(<instance-id>),
	ID:         core.StringPtr(<integration-id>),
}

integrationResponse, response, err := eventNotificationsService.GetIntegration(getIntegrationOptions)
List Integrations

listIntegrationsOptions := &eventnotificationsv1.ListIntegrationsOptions{
	InstanceID: core.StringPtr(<instance-id>),
	Limit:      core.Int64Ptr(<limit>),
	Offset:     core.Int64Ptr(<Offset>),
	Search:     core.StringPtr(<search>),
}

integrationResponse, response, err := eventNotificationsService.ListIntegrations(listIntegrationsOptions)
Update Integration
integrationMetadata := &eventnotificationsv1.IntegrationMetadata{
	Endpoint:  core.StringPtr(<end-point-url>),
	CRN:       core.StringPtr(<crn>),
	RootKeyID: core.StringPtr(<root-key-id>),
}

replaceIntegrationsOptions := &eventnotificationsv1.ReplaceIntegrationOptions{
	InstanceID: core.StringPtr(instanceID),
	ID:         core.StringPtr(integrationId),
	Type:       core.StringPtr(<integration-type>),
	Metadata:   integrationMetadata,
}

integrationResponse, response, err := eventNotificationsService.ReplaceIntegration(replaceIntegrationsOptions)

Send Notifications

notificationevicesModel := map[string]interface{}{
	UserIds: []string{"<user-ids>"},
	FcmDevices: []string{"<fcm-device-ids>"},
	ApnsDevices: []string{"<apns-device-ids>"},
	Tags: []string{"<tag-names>"},
	Platforms: []string{"<device-platforms>"},
}
devicesbody, _ := json.Marshal(notificationevicesModel)
devicesbodyString := string(devicesbody)


notificationID := "<notification-id>"
notificationSeverity := "<notification-severity>"
typeValue := "<notification-type>"
notificationsSouce := "<notification-source>"
specVersion := "1.0"

notificationDevicesModel := "{\"user_ids\": [\"userId\"]}"
notificationFcmBodyModel := "{\"message\": {\"android\": {\"notification\": {\"title\": \"Alert message\",\"body\": \"Bob wants to play Poker\"},\"data\": {\"name\": \"Willie Greenholt\",\"description\": \"notification for the Poker\"}}}}"
notificationAPNsBodyModel := "{\"alert\": \"Game Request\", \"badge\": 5 }"
notificationSafariBodyModel := "{\"aps\":{\"alert\":{\"title\":\"FlightA998NowBoarding\",\"body\":\"BoardinghasbegunforFlightA998.\",\"action\":\"View\"},\"url-args\":[\"boarding\",\"A998\"]}}}"

notificationSeverity := "MEDIUM"
typeValue := "com.acme.offer:new"
notificationsSouce := "1234-1234-sdfs-234:test"
specVersion := "1.0"

notificationCreateModel := &eventnotificationsv1.NotificationCreate{}
notificationCreateModel.Ibmenseverity = &notificationSeverity
notificationCreateModel.ID = &instanceID
notificationCreateModel.Source = &notificationsSouce
notificationCreateModel.Ibmensourceid = &sourceID
notificationCreateModel.Type = &typeValue
notificationCreateModel.Time = &strfmt.DateTime{}
notificationCreateModel.Specversion = &specVersion
notificationCreateModel.Ibmenfcmbody = &notificationFcmBodyModel
notificationCreateModel.Ibmenapnsbody = &notificationAPNsBodyModel
notificationCreateModel.Ibmensafaribody = &notificationSafariBodyModel
notificationCreateModel.Ibmenpushto = &devicesbodyString
notificationCreateModel.Ibmendefaultshort = core.StringPtr("Alert message")
notificationCreateModel.Ibmendefaultlong = core.StringPtr("Alert message on expiring offer")

sendNotificationsOptionsModel := new(eventnotificationsv1.SendNotificationsOptions)
sendNotificationsOptionsModel.InstanceID = &instanceID
sendNotificationsOptionsModel.Body = notificationCreateModel

notificationResponse, response, err := eventNotificationsService.SendNotifications(sendNotificationsOptionsModel)

if err != nil {
	panic(err)
}
Send Notifications Variables
  • Ibmenpushto - Set up the the push notifications tragets.
    • user_ids (Array of String) - Send notification to the specified userIds.
    • fcm_devices (Array of String) - Send notification to the list of specified Android devices.
    • fcm_devices (Array of String) - Send notification to the list of specified iOS devices.
    • _devices (Array of String) - Send notification to the list of specified Chrome devices.
    • firefox_devices (Array of String) - Send notification to the list of specified Firefox devices.
    • tags (Array of String) - Send notification to the devices that have subscribed to any of these tags.
    • platforms (Array of String) - Send notification to the devices of the specified platforms.
      • Pass 'G' for google (Android) devices.
      • Pass 'A' for iOS devices.
      • Pass 'WEB_FIREFOX' for Firefox browser.
      • Pass 'WEB_CHROME' for Chrome browser.
  • ibmenfcmbody - Set payload specific to Android platform [Refer this FCM official link].
  • ibmenfcmbody - Set payload specific to iOS platform [Refer this APNs official doc link].
  • ibmenapnsheaders - Set headers required for the APNs message [Refer this APNs official link(Table 1 Header fields for a POST request)].
  • Event Notificaitons SendNotificationsOptions - Event Notificaitons Send notificaitons method.
    • InstanceID (String) - Event Notificaitons instance AppGUID.
    • ibmenseverity (String) - Severity for the notifications. Some sources can have the concept of an Event severity. Hence a handy way is provided to specify a severity of the event.
    • ID (String) - A unique identifier that identifies each event. source+id must be unique. The backend should be able to uniquely track this id in logs and other records. Send unique ID for each send notification. Same ID can be sent in case of failure of send notification. source+id will be logged in IBM Cloud Logging service. Using this combination we will be able to trace the event movement from one system to another and will aid in debugging and tracing.
    • Source (String) - This is the identifier of the event producer. A way to uniquely identify the source of the event. For IBM Cloud services this is the crn of the service instance producing the events. For API sources this can be something the event producer backend can uniquely identify itself with.
    • Ibmensourceid (String) - This is the ID of the source created in EN. This is available in the EN UI in the "Sources" section.
    • Type (String) - This describes the type of event. It is of the form : This type is defined by the producer. The event type name has to be prefixed with the reverse DNS names so the event type is uniquely identified. The same event type can be produced by 2 different sources. It is highly recommended to use hyphen - as a separator instead of _.
    • Time (String) - Time of the notifications. UTC time stamp when the event occurred. Must be in the RFC 3339 format.
    • Ibmenpushto (string) - Targets for the FCM notifications. This contains details about the destination where you want to send push notification. This attribute is mandatory for successful delivery from an Android FCM or APNS destination
    • Ibmenfcmbody (string) - Message body for the FCM notifications. [Refer this FCM official link].
    • Ibmenapnsbody (string) - Message body for the APNs notifications. [Refer this APNs official doc link].
    • Ibmensafaribody (string) - Message body for the Safari notifications. [Refer this Safari official doc link].
    • Ibmenapnsheaders (string) - Headers for the APNs notifications. [Refer this APNs official link(Table 1 Header fields for a POST request)]
    • Ibmenchromebody (string) - Message body for the Chrome notifications. [Refer this APNs official link(Table 1 Header fields for a POST request)]
    • Ibmenfirefoxbody (string) - Message body for the Firefox notifications. [Refer this official documentation for more].
    • Ibmenchromeheaders (string) - Headers for the Chrome notifications. Refer this official documentation for more.
    • Ibmenfirefoxheaders (string) - Headers for the Firefox notifications. Refer this official documentation for more.
    • Ibmendefaultshort (string) - Default short text for the message.
    • Ibmendefaultlong (string) - Default long text for the message.
    • Specversion (String) - Spec version of the Event Notificaitons. Default value is 1.0.

Set Environment

Find event_notifications_v1.env.hide in the repo and rename it to event_notifications_v1.env. After that add the values for,

  • EVENT_NOTIFICATIONS_URL - Add the Event Notifications service instance Url.
  • EVENT_NOTIFICATIONS_APIKEY - Add the Event Notifications service instance apikey.
  • EVENT_NOTIFICATIONS_GUID - Add the Event Notifications service instance GUID.

Optional

  • EVENT_NOTIFICATIONS_AUTH_URL - Add the IAM url if you are using IBM test cloud.
  • EVENT_NOTIFICATIONS_FCM_KEY - Add firebase server key for Android FCM destination.
  • EVENT_NOTIFICATIONS_FCM_ID - Add firebase sender Id for Android FCM destination.

Questions

If you are having difficulties using this SDK or have a question about the IBM Cloud services, please ask a question at Stack Overflow.

Open source @ IBM

Find more open source projects on the IBM Github Page

Contributing

See CONTRIBUTING.

License

This SDK project is released under the Apache 2.0 license. The license's full text can be found in LICENSE.

Directories

Path Synopsis
Package eventnotificationsv1 : Operations and models for the EventNotificationsV1 service
Package eventnotificationsv1 : Operations and models for the EventNotificationsV1 service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL