001
002package com.commercetools.api.models.subscription;
003
004import java.time.*;
005import java.time.ZonedDateTime;
006import java.util.*;
007import java.util.function.Function;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 *  <p>The CloudEventsFormat represents event data in a way that conforms to a common specification. The message payload can be found inside the <code>data</code> field.</p>
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     CloudEventsPayload cloudEventsPayload = CloudEventsPayload.builder()
026 *             .specversion("{specversion}")
027 *             .id("{id}")
028 *             .type("{type}")
029 *             .source("{source}")
030 *             .subject("{subject}")
031 *             .time(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
032 *             .data(dataBuilder -> dataBuilder)
033 *             .build()
034 * </code></pre>
035 * </div>
036 */
037@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
038@JsonDeserialize(as = CloudEventsPayloadImpl.class)
039public interface CloudEventsPayload {
040
041    /**
042     * discriminator value for CloudEventsPayload
043     */
044    String CLOUD_EVENTS = "CloudEvents";
045
046    /**
047     *  <p>The version of the CloudEvents specification which the event uses.</p>
048     * @return specversion
049     */
050    @NotNull
051    @JsonProperty("specversion")
052    public String getSpecversion();
053
054    /**
055     *  <p>Unique identifier of the event.</p>
056     * @return id
057     */
058    @NotNull
059    @JsonProperty("id")
060    public String getId();
061
062    /**
063     *  <p>The <code>type</code> is namespaced with <code>com.commercetools</code>, followed by the ReferenceTypeId, the type of Subscription (either <code>message</code> or <code>change</code>), and the message or change type. For example, <code>com.commercetools.product.message.ProductPublished</code> or <code>com.commercetools.order.change.ResourceCreated</code>.</p>
064     * @return type
065     */
066    @NotNull
067    @JsonProperty("type")
068    public String getType();
069
070    /**
071     *  <p>The default REST URI of the ReferenceTypeId that triggered this event, including the project key.</p>
072     * @return source
073     */
074    @NotNull
075    @JsonProperty("source")
076    public String getSource();
077
078    /**
079     *  <p>Unique identifier of the resource that triggered the event.</p>
080     * @return subject
081     */
082    @NotNull
083    @JsonProperty("subject")
084    public String getSubject();
085
086    /**
087     *  <p>Corresponds to the <code>lastModifiedAt</code> of the resource at the time the event was triggered.</p>
088     * @return time
089     */
090    @NotNull
091    @JsonProperty("time")
092    public ZonedDateTime getTime();
093
094    /**
095     *  <p>Corresponds to the <code>sequenceNumber</code> of a MessageSubscription. Can be used to process messages in the correct order.</p>
096     * @return sequence
097     */
098
099    @JsonProperty("sequence")
100    public String getSequence();
101
102    /**
103     *  <p><code>"Integer"</code></p>
104     * @return sequencetype
105     */
106
107    @JsonProperty("sequencetype")
108    public String getSequencetype();
109
110    /**
111     *  <p>The URI from which the message can be retrieved if messages are enabled. Only set for MessageSubscriptions.</p>
112     * @return dataref
113     */
114
115    @JsonProperty("dataref")
116    public String getDataref();
117
118    /**
119     *  <p>MessageDeliveryPayload, ResourceCreatedDeliveryPayload, ResourceUpdatedDeliveryPayload, or ResourceDeletedDeliveryPayload.</p>
120     * @return data
121     */
122    @NotNull
123    @Valid
124    @JsonProperty("data")
125    public DeliveryPayload getData();
126
127    /**
128     *  <p>The version of the CloudEvents specification which the event uses.</p>
129     * @param specversion value to be set
130     */
131
132    public void setSpecversion(final String specversion);
133
134    /**
135     *  <p>Unique identifier of the event.</p>
136     * @param id value to be set
137     */
138
139    public void setId(final String id);
140
141    /**
142     *  <p>The <code>type</code> is namespaced with <code>com.commercetools</code>, followed by the ReferenceTypeId, the type of Subscription (either <code>message</code> or <code>change</code>), and the message or change type. For example, <code>com.commercetools.product.message.ProductPublished</code> or <code>com.commercetools.order.change.ResourceCreated</code>.</p>
143     * @param type value to be set
144     */
145
146    public void setType(final String type);
147
148    /**
149     *  <p>The default REST URI of the ReferenceTypeId that triggered this event, including the project key.</p>
150     * @param source value to be set
151     */
152
153    public void setSource(final String source);
154
155    /**
156     *  <p>Unique identifier of the resource that triggered the event.</p>
157     * @param subject value to be set
158     */
159
160    public void setSubject(final String subject);
161
162    /**
163     *  <p>Corresponds to the <code>lastModifiedAt</code> of the resource at the time the event was triggered.</p>
164     * @param time value to be set
165     */
166
167    public void setTime(final ZonedDateTime time);
168
169    /**
170     *  <p>Corresponds to the <code>sequenceNumber</code> of a MessageSubscription. Can be used to process messages in the correct order.</p>
171     * @param sequence value to be set
172     */
173
174    public void setSequence(final String sequence);
175
176    /**
177     *  <p><code>"Integer"</code></p>
178     * @param sequencetype value to be set
179     */
180
181    public void setSequencetype(final String sequencetype);
182
183    /**
184     *  <p>The URI from which the message can be retrieved if messages are enabled. Only set for MessageSubscriptions.</p>
185     * @param dataref value to be set
186     */
187
188    public void setDataref(final String dataref);
189
190    /**
191     *  <p>MessageDeliveryPayload, ResourceCreatedDeliveryPayload, ResourceUpdatedDeliveryPayload, or ResourceDeletedDeliveryPayload.</p>
192     * @param data value to be set
193     */
194
195    public void setData(final DeliveryPayload data);
196
197    /**
198     * factory method
199     * @return instance of CloudEventsPayload
200     */
201    public static CloudEventsPayload of() {
202        return new CloudEventsPayloadImpl();
203    }
204
205    /**
206     * factory method to create a shallow copy CloudEventsPayload
207     * @param template instance to be copied
208     * @return copy instance
209     */
210    public static CloudEventsPayload of(final CloudEventsPayload template) {
211        CloudEventsPayloadImpl instance = new CloudEventsPayloadImpl();
212        instance.setSpecversion(template.getSpecversion());
213        instance.setId(template.getId());
214        instance.setType(template.getType());
215        instance.setSource(template.getSource());
216        instance.setSubject(template.getSubject());
217        instance.setTime(template.getTime());
218        instance.setSequence(template.getSequence());
219        instance.setSequencetype(template.getSequencetype());
220        instance.setDataref(template.getDataref());
221        instance.setData(template.getData());
222        return instance;
223    }
224
225    /**
226     * factory method to create a deep copy of CloudEventsPayload
227     * @param template instance to be copied
228     * @return copy instance
229     */
230    @Nullable
231    public static CloudEventsPayload deepCopy(@Nullable final CloudEventsPayload template) {
232        if (template == null) {
233            return null;
234        }
235        CloudEventsPayloadImpl instance = new CloudEventsPayloadImpl();
236        instance.setSpecversion(template.getSpecversion());
237        instance.setId(template.getId());
238        instance.setType(template.getType());
239        instance.setSource(template.getSource());
240        instance.setSubject(template.getSubject());
241        instance.setTime(template.getTime());
242        instance.setSequence(template.getSequence());
243        instance.setSequencetype(template.getSequencetype());
244        instance.setDataref(template.getDataref());
245        instance.setData(com.commercetools.api.models.subscription.DeliveryPayload.deepCopy(template.getData()));
246        return instance;
247    }
248
249    /**
250     * builder factory method for CloudEventsPayload
251     * @return builder
252     */
253    public static CloudEventsPayloadBuilder builder() {
254        return CloudEventsPayloadBuilder.of();
255    }
256
257    /**
258     * create builder for CloudEventsPayload instance
259     * @param template instance with prefilled values for the builder
260     * @return builder
261     */
262    public static CloudEventsPayloadBuilder builder(final CloudEventsPayload template) {
263        return CloudEventsPayloadBuilder.of(template);
264    }
265
266    /**
267     * accessor map function
268     * @param <T> mapped type
269     * @param helper function to map the object
270     * @return mapped value
271     */
272    default <T> T withCloudEventsPayload(Function<CloudEventsPayload, T> helper) {
273        return helper.apply(this);
274    }
275
276    /**
277     * gives a TypeReference for usage with Jackson DataBind
278     * @return TypeReference
279     */
280    public static com.fasterxml.jackson.core.type.TypeReference<CloudEventsPayload> typeReference() {
281        return new com.fasterxml.jackson.core.type.TypeReference<CloudEventsPayload>() {
282            @Override
283            public String toString() {
284                return "TypeReference<CloudEventsPayload>";
285            }
286        };
287    }
288}