Skip to content

Commit dea3106

Browse files
author
Nicola Dardanis
committed
feat(GH-233): add new Subscriber filtering API support
1 parent 4db8cd7 commit dea3106

File tree

5 files changed

+63
-13
lines changed

5 files changed

+63
-13
lines changed

events_mgmt/src/main/java/com/adobe/aio/event/management/model/CreateSubscriberFilterModel.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
package com.adobe.aio.event.management.model;
1313

14+
import com.fasterxml.jackson.annotation.JsonCreator;
1415
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1516
import com.fasterxml.jackson.annotation.JsonInclude;
1617
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -33,7 +34,11 @@ public class CreateSubscriberFilterModel {
3334
@JsonProperty("subscriber_filter")
3435
private final String subscriberFilter;
3536

36-
public CreateSubscriberFilterModel(String name, String description, String subscriberFilter) {
37+
@JsonCreator
38+
public CreateSubscriberFilterModel(
39+
@JsonProperty("name") String name,
40+
@JsonProperty("description") String description,
41+
@JsonProperty("subscriber_filter") String subscriberFilter) {
3742
this.name = name;
3843
this.description = description;
3944
this.subscriberFilter = subscriberFilter;

events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public class Registration {
8181
@JsonProperty("events_of_interest")
8282
private final Set<EventsOfInterest> eventsOfInterests;
8383

84+
@JsonProperty("subscriber_filters")
85+
private final Set<SubscriberFilterModel> subscriberFilters;
86+
8487
@JsonCreator
8588
public Registration(
8689
@JsonProperty("id") Long id,
@@ -98,7 +101,8 @@ public Registration(
98101
@JsonProperty("webhook_url") String webhookUrl,
99102
@JsonProperty("runtime_action") String runtimeAction,
100103
@JsonProperty("enabled") boolean enabled,
101-
@JsonProperty("events_of_interest") Set<EventsOfInterest> eventsOfInterests) {
104+
@JsonProperty("events_of_interest") Set<EventsOfInterest> eventsOfInterests,
105+
@JsonProperty("subscriber_filters") Set<SubscriberFilterModel> subscriberFilters) {
102106
this.id = id;
103107
this.name = name;
104108
this.description = description;
@@ -115,6 +119,7 @@ public Registration(
115119
this.runtimeAction = runtimeAction;
116120
this.enabled = enabled;
117121
this.eventsOfInterests = eventsOfInterests;
122+
this.subscriberFilters = subscriberFilters;
118123
this.self = self;
119124
this.traceUrl = traceUrl;
120125
this.journalUrl = journalUrl;
@@ -198,6 +203,10 @@ public Set<EventsOfInterest> getEventsOfInterests() {
198203
return eventsOfInterests;
199204
}
200205

206+
public Set<SubscriberFilterModel> getSubscriberFilters() {
207+
return subscriberFilters;
208+
}
209+
201210
@Override public boolean equals(Object o) {
202211
if (this == o) {
203212
return true;
@@ -224,12 +233,13 @@ public Set<EventsOfInterest> getEventsOfInterests() {
224233
Objects.equals(workspaceId, that.workspaceId) &&
225234
Objects.equals(webhookUrl, that.webhookUrl) &&
226235
Objects.equals(runtimeAction, that.runtimeAction) &&
227-
Objects.equals(eventsOfInterests, that.eventsOfInterests);
236+
Objects.equals(eventsOfInterests, that.eventsOfInterests) &&
237+
Objects.equals(subscriberFilters, that.subscriberFilters);
228238
}
229239

230240
@Override public int hashCode() {
231241
return Objects.hash(self, journalUrl, traceUrl, id, name, description, clientId, registrationId, deliveryType, webhookStatus,
232-
createdDate, updatedDate, consumerId, projectId, workspaceId, webhookUrl, runtimeAction, enabled, eventsOfInterests);
242+
createdDate, updatedDate, consumerId, projectId, workspaceId, webhookUrl, runtimeAction, enabled, eventsOfInterests, subscriberFilters);
233243
}
234244

235245
@Override public String toString() {

events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class RegistrationCreateModel extends RegistrationUpdateModel {
3030
private RegistrationCreateModel(final String clientId, final String name, final String description,
3131
final String deliveryType, final String runtimeAction,
3232
final Set<EventsOfInterestInputModel> eventsOfInterestInputModels,
33-
final String webhookUrl, final boolean enabled) {
34-
super(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled);
33+
final String webhookUrl, final boolean enabled, final Set<CreateSubscriberFilterModel> subscriberFilters) {
34+
super(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled, subscriberFilters);
3535
if (StringUtils.isBlank(clientId)) {
3636
throw new IllegalArgumentException(
3737
"Registration is missing a clientId");
@@ -59,7 +59,7 @@ public String getClientId() {
5959

6060
@Override
6161
public int hashCode() {
62-
return Objects.hash(clientId, name, description, deliveryType, runtimeAction, eventsOfInterestInputModels, webhookUrl, enabled);
62+
return Objects.hash(clientId, name, description, deliveryType, runtimeAction, eventsOfInterestInputModels, webhookUrl, enabled, subscriberFilters);
6363
}
6464

6565
@Override
@@ -73,6 +73,7 @@ public String toString() {
7373
", eventsOfInterestInputModels=" + eventsOfInterestInputModels +
7474
", webhookUrl='" + webhookUrl + '\'' +
7575
", enabled='" + enabled + '\'' +
76+
", subscriberFilters=" + subscriberFilters +
7677
'}';
7778
}
7879

@@ -93,7 +94,7 @@ public Builder clientId(String clientId) {
9394
@Override
9495
public RegistrationCreateModel build() {
9596
return new RegistrationCreateModel(clientId, name, description, deliveryType, runtimeAction,
96-
eventsOfInterestInputModels, webhookUrl, enabled);
97+
eventsOfInterestInputModels, webhookUrl, enabled, subscriberFilters);
9798
}
9899
}
99100
}

events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ public class RegistrationUpdateModel {
4444
@JsonProperty("enabled")
4545
protected Boolean enabled;
4646

47+
@JsonProperty("subscriber_filters")
48+
protected Set<CreateSubscriberFilterModel> subscriberFilters;
49+
4750
RegistrationUpdateModel(final String name, final String description, final String webhookUrl,
4851
final Set<EventsOfInterestInputModel> eventsOfInterestInputModels, final String deliveryType,
49-
final String runtimeAction, final Boolean enabled) {
52+
final String runtimeAction, final Boolean enabled,
53+
final Set<CreateSubscriberFilterModel> subscriberFilters) {
5054

5155
if (StringUtils.isBlank(name)){
5256
throw new IllegalArgumentException("Registration is missing a name");
@@ -71,6 +75,7 @@ public class RegistrationUpdateModel {
7175
this.deliveryType = deliveryType;
7276
this.runtimeAction = runtimeAction;
7377
this.enabled = enabled == null || enabled;
78+
this.subscriberFilters = subscriberFilters;
7479
}
7580

7681
public String getName() {
@@ -101,6 +106,11 @@ public String getRuntimeAction() {
101106
return runtimeAction;
102107
}
103108

109+
110+
public Set<CreateSubscriberFilterModel> getSubscriberFilters() {
111+
return subscriberFilters;
112+
}
113+
104114
@Override public boolean equals(Object o) {
105115
if (this == o) {
106116
return true;
@@ -115,12 +125,13 @@ public String getRuntimeAction() {
115125
Objects.equals(eventsOfInterestInputModels, that.eventsOfInterestInputModels) &&
116126
Objects.equals(deliveryType, that.deliveryType) &&
117127
Objects.equals(runtimeAction, that.runtimeAction) &&
118-
Objects.equals(enabled, that.enabled);
128+
Objects.equals(enabled, that.enabled) &&
129+
Objects.equals(subscriberFilters, that.subscriberFilters);
119130
}
120131

121132
@Override
122133
public int hashCode() {
123-
return Objects.hash(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled);
134+
return Objects.hash(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled, subscriberFilters);
124135
}
125136

126137
@Override
@@ -133,6 +144,7 @@ public String toString() {
133144
", deliveryType=" + deliveryType +
134145
", runtimeAction=" + runtimeAction +
135146
", enabled='" + enabled + '\'' +
147+
", subscriberFilters=" + subscriberFilters +
136148
'}';
137149
}
138150

@@ -150,6 +162,7 @@ public static class Builder<T extends Builder> {
150162
protected Set<EventsOfInterestInputModel> eventsOfInterestInputModels = new HashSet<>();
151163
protected String webhookUrl;
152164
protected Boolean enabled = Boolean.TRUE;
165+
protected Set<CreateSubscriberFilterModel> subscriberFilters = new HashSet<>();
153166

154167
public Builder() {
155168
}
@@ -196,10 +209,25 @@ public T enabled(Boolean enabled) {
196209
return (T) this;
197210
}
198211

212+
public T addSubscriberFilter(CreateSubscriberFilterModel subscriberFilter) {
213+
this.subscriberFilters.add(subscriberFilter);
214+
return (T) this;
215+
}
216+
217+
public T addSubscriberFilters(Set<CreateSubscriberFilterModel> subscriberFilters) {
218+
this.subscriberFilters.addAll(subscriberFilters);
219+
return (T) this;
220+
}
221+
222+
public T subscriberFilters(Set<CreateSubscriberFilterModel> subscriberFilters) {
223+
this.subscriberFilters = subscriberFilters != null ? subscriberFilters : new HashSet<>();
224+
return (T) this;
225+
}
226+
199227
public RegistrationUpdateModel build() {
200228
return new RegistrationUpdateModel(name, description, webhookUrl,
201229
eventsOfInterestInputModels, deliveryType, runtimeAction,
202-
enabled);
230+
enabled, subscriberFilters);
203231
}
204232
}
205233
}

events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterModel.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
package com.adobe.aio.event.management.model;
1313

14+
import com.fasterxml.jackson.annotation.JsonCreator;
1415
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1516
import com.fasterxml.jackson.annotation.JsonInclude;
1617
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -28,7 +29,12 @@ public class SubscriberFilterModel extends CreateSubscriberFilterModel {
2829
@JsonProperty("id")
2930
private final UUID id;
3031

31-
public SubscriberFilterModel(UUID id, String name, String description, String subscriberFilter) {
32+
@JsonCreator
33+
public SubscriberFilterModel(
34+
@JsonProperty("id") UUID id,
35+
@JsonProperty("name") String name,
36+
@JsonProperty("description") String description,
37+
@JsonProperty("subscriber_filter") String subscriberFilter) {
3238
super(name, description, subscriberFilter);
3339
this.id = id;
3440
}

0 commit comments

Comments
 (0)