github.com/argoproj/argo-events@v1.9.1/eventsources/sources/awssns/types.go (about)

     1  /*
     2  Copyright 2018 BlackRock, Inc.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package awssns
    18  
    19  import (
    20  	"time"
    21  
    22  	"github.com/argoproj/argo-events/eventsources/common/webhook"
    23  	"github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1"
    24  	snslib "github.com/aws/aws-sdk-go/service/sns"
    25  )
    26  
    27  const (
    28  	messageTypeSubscriptionConfirmation = "SubscriptionConfirmation"
    29  	messageTypeNotification             = "Notification"
    30  )
    31  
    32  // Router contains information for a route
    33  type Router struct {
    34  	// Route contains webhook context and configuration related to api route
    35  	Route *webhook.Route
    36  	// eventSource refers to sns event source configuration
    37  	eventSource *v1alpha1.SNSEventSource
    38  	// session refers to aws session
    39  	session *snslib.SNS
    40  	// subscriptionArn is sns arn
    41  	subscriptionArn *string
    42  }
    43  
    44  // Json http notifications
    45  // SNS posts those to your http url endpoint if http is selected as delivery method.
    46  // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-subscription-confirmation-json
    47  // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-notification-json
    48  // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-unsubscribe-confirmation-json
    49  type httpNotification struct {
    50  	Type             string    `json:"Type"`
    51  	MessageID        string    `json:"MessageId"`
    52  	Token            string    `json:"Token,omitempty"` // Only for subscribe and unsubscribe
    53  	TopicArn         string    `json:"TopicArn"`
    54  	Subject          string    `json:"Subject,omitempty"` // Only for Notification
    55  	Message          string    `json:"Message"`
    56  	SubscribeURL     string    `json:"SubscribeURL,omitempty"` // Only for subscribe and unsubscribe
    57  	Timestamp        time.Time `json:"Timestamp"`
    58  	SignatureVersion string    `json:"SignatureVersion"`
    59  	Signature        string    `json:"Signature"`
    60  	SigningCertURL   string    `json:"SigningCertURL"`
    61  	UnsubscribeURL   string    `json:"UnsubscribeURL,omitempty"` // Only for notifications
    62  }