001/*
002Copyright 2022 The OpenFunction Authors.
003
004Licensed under the Apache License, Version 2.0 (the "License");
005you may not use this file except in compliance with the License.
006You may obtain a copy of the License at
007
008    http://www.apache.org/licenses/LICENSE-2.0
009
010Unless required by applicable law or agreed to in writing, software
011distributed under the License is distributed on an "AS IS" BASIS,
012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013See the License for the specific language governing permissions and
014limitations under the License.
015*/
016
017package dev.openfunction.functions;
018
019import java.nio.ByteBuffer;
020
021public class TopicEvent {
022    /**
023     * The name of the pubsub the publisher sent to.
024     */
025    private final String name;
026
027    /**
028     * ID identifies the event.
029     */
030    private final String id;
031
032    /**
033     * The version of the CloudEvents specification.
034     */
035    private final String specversion;
036
037    /**
038     * The type of event related to the originating occurrence.
039     */
040    private final String type;
041
042    /**
043     * Source identifies the context in which an event happened.
044     */
045    private final String source;
046
047    /**
048     *
049     */
050    private final String datacontenttype;
051
052    /**
053     * The content of the event.
054     * Note, this is why the gRPC and HTTP implementations need separate structs for cloud events.
055     */
056    private final ByteBuffer data;
057
058    /**
059     * The pubsub topic which publisher sent to.
060     */
061    private final String topic;
062
063    public TopicEvent(String name, String id, String topic, String specversion, String source, String type, String datacontenttype, ByteBuffer data) {
064        this.name = name;
065        this.id = id;
066        this.topic = topic;
067        this.specversion = specversion;
068        this.source = source;
069        this.type = type;
070        this.datacontenttype = datacontenttype;
071        this.data = data;
072    }
073
074    public String getName() {
075        return name;
076    }
077
078    public String getId() {
079        return id;
080    }
081
082    public String getSpecversion() {
083        return specversion;
084    }
085
086    public String getType() {
087        return type;
088    }
089
090    public String getSource() {
091        return source;
092    }
093
094    public String getDatacontenttype() {
095        return datacontenttype;
096    }
097
098    public ByteBuffer getData() {
099        return data;
100    }
101
102    public String getTopic() {
103        return topic;
104    }
105}