github.com/argoproj/argo-events@v1.9.1/pkg/apis/events/event-data.go (about)

     1  /*
     2  Copyright 2020 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  package events
    17  
    18  import (
    19  	"encoding/json"
    20  	"net/http"
    21  	"time"
    22  
    23  	"github.com/minio/minio-go/v7/pkg/notification"
    24  	"github.com/stripe/stripe-go"
    25  
    26  	sqslib "github.com/aws/aws-sdk-go/service/sqs"
    27  )
    28  
    29  // AMQPEventData represents the event data generated by AMQP eventsource.
    30  type AMQPEventData struct {
    31  	// ContentType is the MIME content type
    32  	ContentType string `json:"contentType"`
    33  	// ContentEncoding is the MIME content encoding
    34  	ContentEncoding string `json:"contentEncoding"`
    35  	// Delivery mode can be either - non-persistent (1) or persistent (2)
    36  	DeliveryMode int `json:"deliveryMode"`
    37  	// Priority refers to the use - 0 to 9
    38  	Priority int `json:"priority"`
    39  	// CorrelationId is the correlation identifier
    40  	CorrelationId string `json:"correlationId"`
    41  	// ReplyTo is the address to reply to (ex: RPC)
    42  	ReplyTo string `json:"replyTo"`
    43  	// Expiration refers to message expiration spec
    44  	Expiration string `json:"expiration"`
    45  	// MessageId is message identifier
    46  	MessageId string `json:"messageId"`
    47  	// Timestamp refers to the message timestamp
    48  	Timestamp string `json:"timestamp"`
    49  	// Type refers to the message type name
    50  	Type string `json:"type"`
    51  	// AppId refers to the application id
    52  	AppId string `json:"appId"`
    53  	// Exchange is basic.publish exchange
    54  	Exchange string `json:"exchange"`
    55  	// RoutingKey is basic.publish routing key
    56  	RoutingKey string `json:"routingKey"`
    57  	// Body represents the messsage body
    58  	Body interface{} `json:"body"`
    59  	// Metadata holds the user defined metadata which will passed along the event payload.
    60  	Metadata map[string]string `json:"metadata,omitempty"`
    61  }
    62  
    63  // SNSEventData represents the event data generated by SNS eventsource.
    64  // +k8s:openapi-gen=true
    65  type SNSEventData struct {
    66  	// Header is the http request header
    67  	Header http.Header `json:"header"`
    68  	// Body is http request body
    69  	Body *json.RawMessage `json:"body"`
    70  	// Metadata holds the user defined metadata which will passed along the event payload.
    71  	Metadata map[string]string `json:"metadata,omitempty"`
    72  }
    73  
    74  // SQSEventData represents the event data generated by SQS eventsource.
    75  // +k8s:openapi-gen=true
    76  type SQSEventData struct {
    77  	// A unique identifier for the message. A MessageId is considered unique across
    78  	// all AWS accounts for an extended period of time.
    79  	MessageId string `json:"messageId"`
    80  	// Each message attribute consists of a Name, Type, and Value. For more information,
    81  	// see Amazon SQS Message Attributes
    82  	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html)
    83  	// in the Amazon Simple Queue Service Developer Guide.
    84  	MessageAttributes map[string]*sqslib.MessageAttributeValue `json:"messageAttributes"`
    85  	// The message's contents (not URL-encoded).
    86  	Body interface{} `json:"body"`
    87  	// Metadata holds the user defined metadata which will passed along the event payload.
    88  	Metadata map[string]string `json:"metadata,omitempty"`
    89  }
    90  
    91  // AzureEventsHubEventData represents to the event data generated by Azure Events Hub eventsource.
    92  // +k8s:openapi-gen=true
    93  type AzureEventsHubEventData struct {
    94  	// Id of the message
    95  	Id string `json:"id"`
    96  	// PartitionKey
    97  	PartitionKey string `json:"partitionKey"`
    98  	// Message body
    99  	Body interface{} `json:"body"`
   100  	// Metadata holds the user defined metadata which will passed along the event payload.
   101  	Metadata map[string]string `json:"metadata,omitempty"`
   102  }
   103  
   104  // AzureQueueStorageEventData represents the event data generated by AQS eventsource.
   105  // +k8s:openapi-gen=true
   106  type AzureQueueStorageEventData struct {
   107  	// Body is the message body
   108  	Body interface{} `json:"body"`
   109  	// MessageID is the ID of the message
   110  	MessageID string `json:"messageID"`
   111  	// InsertionTime is the time the Message was inserted into the Queue.
   112  	InsertionTime time.Time `json:"insertionTime"`
   113  	// Metadata holds the user defined metadata which will passed along the event payload.
   114  	Metadata map[string]string `json:"metadata,omitempty"`
   115  }
   116  
   117  type AzureServiceBusEventData struct {
   118  	// ApplicationProperties can be used to store custom metadata for a message
   119  	ApplicationProperties map[string]interface{} `json:"applicationProperties"`
   120  	// Message body
   121  	Body interface{} `json:"body"`
   122  	// ContentType is the MIME content type
   123  	ContentType *string `json:"contentType"`
   124  	// CorrelationID is the correlation identifier
   125  	CorrelationID *string `json:"correlationID"`
   126  	// EnqueuedTime is the time when the message was enqueued
   127  	EnqueuedTime *time.Time `json:"enqueuedTime"`
   128  	// ID of the message
   129  	MessageID string `json:"messageID"`
   130  	// ReplyTo is an application-defined value specify a reply path to the receiver of the message
   131  	ReplyTo *string `json:"replyTo"`
   132  	// SequenceNumber is a unique number assigned to a message by Service Bus
   133  	SequenceNumber *int64 `json:"sequenceNumber"`
   134  	// Subject enables an application to indicate the purpose of the message, similar to an email subject line
   135  	Subject *string `json:"subject"`
   136  	// Metadata holds the user defined metadata which will passed along the event payload
   137  	Metadata map[string]string `json:"metadata,omitempty"`
   138  }
   139  
   140  // BitbucketEventData represents the event data generated by the Bitbucket Server eventsource.
   141  type BitbucketEventData struct {
   142  	// Headers from the Bitbucket Server http request.
   143  	Headers http.Header `json:"headers"`
   144  	// Body represents the message body
   145  	Body *json.RawMessage `json:"body"`
   146  	// Metadata holds the user defined metadata which will passed along the event payload.
   147  	Metadata map[string]string `json:"metadata,omitempty"`
   148  }
   149  
   150  // BitbucketServerEventData represents the event data generated by the Bitbucket Server eventsource.
   151  type BitbucketServerEventData struct {
   152  	// Headers from the Bitbucket Server http request.
   153  	Headers http.Header `json:"headers"`
   154  	// Body represents the message body
   155  	Body *json.RawMessage `json:"body"`
   156  	// Metadata holds the user defined metadata which will passed along the event payload.
   157  	Metadata map[string]string `json:"metadata,omitempty"`
   158  }
   159  
   160  // CalendarEventData represents the event data generated by the Calendar eventsource.
   161  // +k8s:openapi-gen=true
   162  type CalendarEventData struct {
   163  	// EventTime is time at which event occurred
   164  	EventTime string `json:"eventTime"`
   165  	// Metadata holds the user defined metadata which will passed along the event payload.
   166  	Metadata map[string]string `json:"metadata,omitempty"`
   167  }
   168  
   169  // EmitterEventData represents the event data generated by the Emitter eventsource.
   170  type EmitterEventData struct {
   171  	// Topic name
   172  	Topic string `json:"topic"`
   173  	// Body represents the message body
   174  	Body interface{} `json:"body"`
   175  	// Metadata holds the user defined metadata which will passed along the event payload.
   176  	Metadata map[string]string `json:"metadata,omitempty"`
   177  }
   178  
   179  // PubSubEventData represents the event data generated by the GCP PubSub eventsource.
   180  type PubSubEventData struct {
   181  	// ID of the message
   182  	ID string `json:"id"`
   183  	// Body is the actual data in the message.
   184  	Body interface{} `json:"body"`
   185  	// Attributes represents the key-value pairs the current message
   186  	// is labelled with.
   187  	Attributes map[string]string `json:"attributes"`
   188  	// The time at which the message was published.
   189  	PublishTime string `json:"publishTime"`
   190  	// Metadata holds the user defined metadata which will passed along the event payload.
   191  	Metadata map[string]string `json:"metadata,omitempty"`
   192  }
   193  
   194  // GerritEventData represents the event data generated by the Gerrit eventsource.
   195  type GerritEventData struct {
   196  	// Headers from the Gerrit http request.
   197  	Headers http.Header `json:"headers"`
   198  	// Body represents the message body
   199  	Body *json.RawMessage `json:"body"`
   200  	// Metadata holds the user defined metadata which will passed along the event payload.
   201  	Metadata map[string]string `json:"metadata,omitempty"`
   202  }
   203  
   204  // GithubEventData represents the event data generated by the GitHub eventsource.
   205  type GithubEventData struct {
   206  	// Headers from the GitHub http request.
   207  	Headers http.Header `json:"headers"`
   208  	// Body represents the message body
   209  	Body *json.RawMessage `json:"body"`
   210  	// Metadata holds the user defined metadata which will passed along the event payload.
   211  	Metadata map[string]string `json:"metadata,omitempty"`
   212  }
   213  
   214  // GitLabEventData represents the event data generated by the GitLab eventsource.
   215  type GitLabEventData struct {
   216  	// Headers from the Gitlab http request.
   217  	Headers http.Header `json:"headers"`
   218  	// Body represents the message body
   219  	Body *json.RawMessage `json:"body"`
   220  	// Metadata holds the user defined metadata which will passed along the event payload.
   221  	Metadata map[string]string `json:"metadata,omitempty"`
   222  }
   223  
   224  // KafkaEventData represents the event data generated by the Kafka eventsource.
   225  type KafkaEventData struct {
   226  	// Topic refers to the Kafka topic
   227  	Topic string `json:"topic"`
   228  	// Key refers to the Kafka key
   229  	Key string `json:"key"`
   230  	// Partition refers to the Kafka partition
   231  	Partition int `json:"partition"`
   232  	// Body refers to the message value
   233  	Body interface{} `json:"body"`
   234  	// Timestamp of the message
   235  	Timestamp string `json:"timestamp"`
   236  	// Headers refers to the message headers
   237  	Headers map[string]string `json:"headers"`
   238  	// Metadata holds the user defined metadata which will passed along the event payload.
   239  	Metadata map[string]string `json:"metadata,omitempty"`
   240  }
   241  
   242  // MinioEventData represents the event data generated by the Minio eventsource.
   243  type MinioEventData struct {
   244  	Notification []notification.Event `json:"notification"`
   245  	// Metadata holds the user defined metadata which will passed along the event payload.
   246  	Metadata map[string]string `json:"metadata,omitempty"`
   247  }
   248  
   249  // MQTTEventData represents the event data generated by the MQTT eventsource.
   250  type MQTTEventData struct {
   251  	// Topic refers to the MQTT topic name.
   252  	Topic string `json:"topic"`
   253  	// MessageID is the unique ID for the message
   254  	MessageID int `json:"messageId"`
   255  	// Body is the message payload.
   256  	Body interface{} `json:"body"`
   257  	// Metadata holds the user defined metadata which will passed along the event payload.
   258  	Metadata map[string]string `json:"metadata,omitempty"`
   259  }
   260  
   261  // NATSEventData represents the event data generated by the NATS eventsource.
   262  type NATSEventData struct {
   263  	// Name of the subject.
   264  	Subject string `json:"subject"`
   265  	// Message data.
   266  	Body interface{} `json:"body"`
   267  	// Header represents the optional Header for a NATS message, based on the implementation of http.Header.
   268  	Header map[string][]string `json:"header,omitempty"`
   269  	// Metadata holds the user defined metadata which will passed along the event payload.
   270  	Metadata map[string]string `json:"metadata,omitempty"`
   271  }
   272  
   273  // NSQEventData represents the event data generated by the NSQ eventsource.
   274  type NSQEventData struct {
   275  	// Body is the message data.
   276  	Body interface{} `json:"body"`
   277  	// Timestamp of the message.
   278  	Timestamp string `json:"timestamp"`
   279  	// NSQDAddress is the address of the nsq host.
   280  	NSQDAddress string `json:"nsqdAddress"`
   281  	// Metadata holds the user defined metadata which will passed along the event payload.
   282  	Metadata map[string]string `json:"metadata,omitempty"`
   283  }
   284  
   285  // RedisEventData represents the event data generated by the Redis eventsource.
   286  type RedisEventData struct {
   287  	// Subscription channel.
   288  	Channel string `json:"channel"`
   289  	// Message pattern
   290  	Pattern string `json:"pattern"`
   291  	// Message body
   292  	Body interface{} `json:"body"`
   293  	// Metadata holds the user defined metadata which will passed along the event payload.
   294  	Metadata map[string]string `json:"metadata,omitempty"`
   295  }
   296  
   297  // RedisStreamEventData represents the event data generated by the Redis eventsource.
   298  type RedisStreamEventData struct {
   299  	// Source redis stream name.
   300  	Stream string `json:"stream"`
   301  	// Message Id
   302  	Id string `json:"message_id"`
   303  	// Message body
   304  	Values map[string]interface{} `json:"values"`
   305  	// Metadata holds the user defined metadata which will passed along the event payload.
   306  	Metadata map[string]string `json:"metadata,omitempty"`
   307  }
   308  
   309  // ResourceEventData represents the event data generated by the Resource eventsource.
   310  type ResourceEventData struct {
   311  	// EventType of the type of the event.
   312  	EventType string `json:"type"`
   313  	// Resource body.
   314  	Body *json.RawMessage `json:"body"`
   315  	// Prior state of the resource body (if it exists)
   316  	OldBody *json.RawMessage `json:"oldBody"`
   317  	// Resource group name.
   318  	Group string `json:"group"`
   319  	// Resource version.
   320  	Version string `json:"version"`
   321  	// Resource name.
   322  	Resource string `json:"resource"`
   323  	// Metadata holds the user defined metadata which will passed along the event payload.
   324  	Metadata map[string]string `json:"metadata,omitempty"`
   325  }
   326  
   327  // WebhookEventData represents the event data generated by the Webhook eventsource.
   328  type WebhookEventData struct {
   329  	// Header is the http request header
   330  	Header http.Header `json:"header"`
   331  	// Body is http request body
   332  	Body *json.RawMessage `json:"body"`
   333  	// Metadata holds the user defined metadata which will passed along the event payload.
   334  	Metadata map[string]string `json:"metadata,omitempty"`
   335  }
   336  
   337  // PulsarEventData represents the event data generated by the Pulsar eventsource.
   338  type PulsarEventData struct {
   339  	// Key of the message
   340  	Key string `json:"key"`
   341  	// Publish time of the message in UTC
   342  	PublishTime string `json:"publishTime"`
   343  	// Body refers to the message payload
   344  	Body interface{} `json:"body"`
   345  	// Metadata holds the user defined metadata which will passed along the event payload.
   346  	Metadata map[string]string `json:"metadata,omitempty"`
   347  }
   348  
   349  // StorageGridEventData represents the event data generated by the StorageGrid eventsource.
   350  type StorageGridEventData struct {
   351  	Notification *StorageGridNotification `json:"notification"`
   352  	// Metadata holds the user defined metadata which will passed along the event payload.
   353  	Metadata map[string]string `json:"metadata,omitempty"`
   354  }
   355  
   356  // StorageGridNotification is the bucket notification received from storage grid
   357  type StorageGridNotification struct {
   358  	Action  string `json:"Action"`
   359  	Message struct {
   360  		Records []struct {
   361  			EventVersion string    `json:"eventVersion"`
   362  			EventSource  string    `json:"storageGridEventSource"`
   363  			EventTime    time.Time `json:"eventTime"`
   364  			EventName    string    `json:"eventName"`
   365  			UserIdentity struct {
   366  				PrincipalID string `json:"principalId"`
   367  			} `json:"userIdentity"`
   368  			RequestParameters struct {
   369  				SourceIPAddress string `json:"sourceIPAddress"`
   370  			} `json:"requestParameters"`
   371  			ResponseElements struct {
   372  				XAmzRequestID string `json:"x-amz-request-id"`
   373  			} `json:"responseElements"`
   374  			S3 struct {
   375  				S3SchemaVersion string `json:"s3SchemaVersion"`
   376  				ConfigurationID string `json:"configurationId"`
   377  				Bucket          struct {
   378  					Name          string `json:"name"`
   379  					OwnerIdentity struct {
   380  						PrincipalID string `json:"principalId"`
   381  					} `json:"ownerIdentity"`
   382  					Arn string `json:"arn"`
   383  				} `json:"bucket"`
   384  				Object struct {
   385  					Key       string `json:"key"`
   386  					Size      int    `json:"size"`
   387  					ETag      string `json:"eTag"`
   388  					Sequencer string `json:"sequencer"`
   389  				} `json:"object"`
   390  			} `json:"s3"`
   391  		} `json:"Records"`
   392  	} `json:"Message"`
   393  	TopicArn string `json:"TopicArn"`
   394  	Version  string `json:"Version"`
   395  }
   396  
   397  // StripeEventData represents the event data generated by the Stripe eventsource.
   398  type StripeEventData struct {
   399  	Event *stripe.Event `json:"event"`
   400  	// Metadata holds the user defined metadata which will passed along the event payload.
   401  	Metadata map[string]string `json:"metadata,omitempty"`
   402  }
   403  
   404  // GenericEventData represents the event data generated by the generic eventsource.
   405  type GenericEventData struct {
   406  	// Body refers to the message payload
   407  	Body interface{} `json:"body"`
   408  	// Metadata holds the user defined metadata which will passed along the event payload.
   409  	Metadata map[string]string `json:"metadata,omitempty"`
   410  }