diff --git a/.github/workflows/maven-itest.yml b/.github/workflows/maven-itest.yml index 2068225b..ccca48c7 100644 --- a/.github/workflows/maven-itest.yml +++ b/.github/workflows/maven-itest.yml @@ -18,44 +18,6 @@ on: - main jobs: - stage_itest: - runs-on: ubuntu-latest - environment: aio_stage - strategy: - fail-fast: true - - steps: - - # Check out Git repository - - name: Checkout code - uses: actions/checkout@v3 - - # Set up environment with Java and Maven - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - cache: maven - - # Build & Test - - name: Stage Integration Test with Maven - run: mvn -Daio_publish_url=$aio_publish_url -Daio_api_url=$aio_api_url -Daio_ims_url=$aio_ims_url -Daio_meta_scopes=$aio_meta_scopes -Daio_ims_org_id=$aio_ims_org_id -Daio_consumer_org_id=$aio_consumer_org_id -Daio_project_id=$aio_project_id -Daio_workspace_id=$aio_workspace_id -Daio_credential_id=$aio_credential_id -Daio_technical_account_id=$aio_technical_account_id -Daio_api_key=$aio_api_key -Daio_client_secret=$aio_client_secret -Daio_encoded_pkcs8=$aio_encoded_pkcs8 verify -Pitest - env: - aio_ims_url: ${{ secrets.aio_ims_url }} - aio_meta_scopes: ${{ secrets.aio_meta_scopes }} - aio_ims_org_id: ${{ secrets.aio_ims_org_id }} - aio_consumer_org_id: ${{ secrets.aio_consumer_org_id }} - aio_project_id: ${{ secrets.aio_project_id }} - aio_workspace_id: ${{ secrets.aio_workspace_id }} - aio_credential_id: ${{ secrets.aio_credential_id }} - aio_technical_account_id: ${{ secrets.aio_technical_account_id }} - aio_api_key: ${{ secrets.aio_api_key }} - aio_client_secret: ${{ secrets.aio_client_secret }} - aio_encoded_pkcs8: ${{ secrets.aio_encoded_pkcs8 }} - aio_api_url: ${{ secrets.aio_api_url }} - aio_publish_url: ${{ secrets.aio_publish_url }} - stage_oauth_itest: runs-on: ubuntu-latest environment: aio_stage_oauth @@ -91,9 +53,9 @@ jobs: aio_api_url: ${{ secrets.aio_api_url }} aio_publish_url: ${{ secrets.aio_publish_url }} - prod_itest: + prod_oauth_itest: runs-on: ubuntu-latest - environment: aio_prod + environment: prod_oauth_itest strategy: fail-fast: true @@ -113,18 +75,15 @@ jobs: # Build & Test - name: Prod Integration Test with Maven - run: mvn -Daio_publish_url=$aio_publish_url -Daio_api_url=$aio_api_url -Daio_ims_url=$aio_ims_url -Daio_meta_scopes=$aio_meta_scopes -Daio_ims_org_id=$aio_ims_org_id -Daio_consumer_org_id=$aio_consumer_org_id -Daio_project_id=$aio_project_id -Daio_workspace_id=$aio_workspace_id -Daio_credential_id=$aio_credential_id -Daio_technical_account_id=$aio_technical_account_id -Daio_api_key=$aio_api_key -Daio_client_secret=$aio_client_secret -Daio_encoded_pkcs8=$aio_encoded_pkcs8 verify -Pitest + run: mvn -Daio_publish_url=$aio_publish_url -Daio_api_url=$aio_api_url -Daio_ims_url=$aio_ims_url -Daio_oauth_scopes=$aio_oauth_scopes -Daio_ims_org_id=$aio_ims_org_id -Daio_consumer_org_id=$aio_consumer_org_id -Daio_project_id=$aio_project_id -Daio_workspace_id=$aio_workspace_id -Daio_api_key=$aio_api_key -Daio_client_secret=$aio_client_secret verify -Pitest env: aio_ims_url: ${{ secrets.aio_ims_url }} - aio_meta_scopes: ${{ secrets.aio_meta_scopes }} + aio_client_secret: ${{ secrets.aio_client_secret }} + aio_oauth_scopes: ${{ secrets.aio_oauth_scopes }} aio_ims_org_id: ${{ secrets.aio_ims_org_id }} aio_consumer_org_id: ${{ secrets.aio_consumer_org_id }} aio_project_id: ${{ secrets.aio_project_id }} aio_workspace_id: ${{ secrets.aio_workspace_id }} - aio_credential_id: ${{ secrets.aio_credential_id }} - aio_technical_account_id: ${{ secrets.aio_technical_account_id }} aio_api_key: ${{ secrets.aio_api_key }} - aio_client_secret: ${{ secrets.aio_client_secret }} - aio_encoded_pkcs8: ${{ secrets.aio_encoded_pkcs8 }} aio_api_url: ${{ secrets.aio_api_url }} aio_publish_url: ${{ secrets.aio_publish_url }} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java index 88071993..e8bf97e3 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java @@ -12,13 +12,19 @@ package com.adobe.aio.event.management; import com.adobe.aio.event.management.feign.FeignRegistrationService; +import com.adobe.aio.event.management.model.CreateSubscriberFilterModel; import com.adobe.aio.event.management.model.Registration; import com.adobe.aio.event.management.model.RegistrationCreateModel; import com.adobe.aio.event.management.model.RegistrationPaginatedModel; import com.adobe.aio.event.management.model.RegistrationUpdateModel; +import com.adobe.aio.event.management.model.SubscriberFilterModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationInputModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationOutputModel; import com.adobe.aio.workspace.Workspace; import java.util.List; import java.util.Optional; +import java.util.Set; +import java.util.UUID; public interface RegistrationService { @@ -40,6 +46,59 @@ default Optional getAllRegistrationsForOrg() { Optional getAllRegistrationsForOrg(long page, long size); + /** + * Validates a subscriber filter for a registration + * + * @param registrationId The registration ID + * @param validationInput The validation input containing the filter and optional custom sample events + * @return SubscriberFilterValidationOutputModel + */ + Optional validateSubscriberFilter(String registrationId, SubscriberFilterValidationInputModel validationInput); + + /** + * Creates a new subscriber filter for a registration + * + * @param registrationId The registration ID + * @param createSubscriberFilterModel The subscriber filter to create + * @return SubscriberFilterModel + */ + Optional createSubscriberFilter(String registrationId, CreateSubscriberFilterModel createSubscriberFilterModel); + + /** + * Gets all subscriber filters for a registration + * + * @param registrationId The registration ID + * @return Set of SubscriberFilterModel + */ + Optional> getAllSubscriberFilters(String registrationId); + + /** + * Gets a specific subscriber filter by ID + * + * @param registrationId The registration ID + * @param subscriberFilterId The subscriber filter ID + * @return SubscriberFilterModel + */ + Optional getSubscriberFilterById(String registrationId, UUID subscriberFilterId); + + /** + * Updates a subscriber filter + * + * @param registrationId The registration ID + * @param subscriberFilterId The subscriber filter ID + * @param updateSubscriberFilterModel The updated subscriber filter + * @return SubscriberFilterModel + */ + Optional updateSubscriberFilter(String registrationId, UUID subscriberFilterId, CreateSubscriberFilterModel updateSubscriberFilterModel); + + /** + * Deletes a subscriber filter + * + * @param registrationId The registration ID + * @param subscriberFilterId The subscriber filter ID + */ + void deleteSubscriberFilter(String registrationId, UUID subscriberFilterId); + static Builder builder() { return new Builder(); } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java index 148e162f..f77364c3 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java @@ -11,15 +11,21 @@ */ package com.adobe.aio.event.management.api; +import com.adobe.aio.event.management.model.CreateSubscriberFilterModel; import com.adobe.aio.event.management.model.Registration; import com.adobe.aio.event.management.model.RegistrationCollection; import com.adobe.aio.event.management.model.RegistrationCreateModel; import com.adobe.aio.event.management.model.RegistrationPaginatedModel; import com.adobe.aio.event.management.model.RegistrationUpdateModel; +import com.adobe.aio.event.management.model.SubscriberFilterModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationInputModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationOutputModel; import feign.Headers; import feign.Param; import feign.RequestLine; import java.util.Optional; +import java.util.Set; +import java.util.UUID; @Headers({"Accept: application/hal+json"}) public interface RegistrationApi { @@ -124,5 +130,122 @@ void delete( @Param("registrationId") String registrationId ); + /** + * Validates a subscriber filter for a registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param body The validation input containing the filter and optional custom sample events + * @return SubscriberFilterValidationOutputModel + */ + @RequestLine("POST /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filter/validate") + @Headers({"Content-Type: application/json", "Accept: application/json"}) + Optional validateFilters( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + SubscriberFilterValidationInputModel body + ); + + /** + * Creates a new subscriber filter for a registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param body The subscriber filter to create + * @return SubscriberFilterModel + */ + @RequestLine("POST /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filters") + @Headers({"Content-Type: application/json", "Accept: application/json"}) + Optional createSubscriberFilter( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + CreateSubscriberFilterModel body + ); + + /** + * Gets all subscriber filters for a registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @return Set of SubscriberFilterModel + */ + @RequestLine("GET /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filters") + @Headers({"Accept: application/json"}) + Optional> getAllSubscriberFilters( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId + ); + + /** + * Gets a specific subscriber filter by ID + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param subscriberFilterId The Subscriber Filter Id + * @return SubscriberFilterModel + */ + @RequestLine("GET /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filters/{subscriberFilterId}") + @Headers({"Accept: application/json"}) + Optional getSubscriberFilterById( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + @Param("subscriberFilterId") UUID subscriberFilterId + ); + + /** + * Updates a subscriber filter + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param subscriberFilterId The Subscriber Filter Id + * @param body The updated subscriber filter + * @return SubscriberFilterModel + */ + @RequestLine("PUT /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filters/{subscriberFilterId}") + @Headers({"Content-Type: application/json", "Accept: application/json"}) + Optional updateSubscriberFilter( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + @Param("subscriberFilterId") UUID subscriberFilterId, + CreateSubscriberFilterModel body + ); + + /** + * Deletes a subscriber filter + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param subscriberFilterId The Subscriber Filter Id + */ + @RequestLine("DELETE /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}/filters/{subscriberFilterId}") + void deleteSubscriberFilter( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + @Param("subscriberFilterId") UUID subscriberFilterId + ); } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java index 0ee1cacb..45a32d80 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java @@ -15,11 +15,15 @@ import com.adobe.aio.event.management.RegistrationService; import com.adobe.aio.event.management.api.RegistrationApi; +import com.adobe.aio.event.management.model.CreateSubscriberFilterModel; import com.adobe.aio.event.management.model.Registration; import com.adobe.aio.event.management.model.RegistrationCollection; import com.adobe.aio.event.management.model.RegistrationCreateModel; import com.adobe.aio.event.management.model.RegistrationPaginatedModel; import com.adobe.aio.event.management.model.RegistrationUpdateModel; +import com.adobe.aio.event.management.model.SubscriberFilterModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationInputModel; +import com.adobe.aio.event.management.model.SubscriberFilterValidationOutputModel; import com.adobe.aio.feign.AIOHeaderInterceptor; import com.adobe.aio.ims.feign.AuthInterceptor; import com.adobe.aio.util.feign.FeignUtil; @@ -28,6 +32,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.Set; +import java.util.UUID; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -113,4 +119,78 @@ public Optional updateRegistration(String registrationId, public Optional getAllRegistrationsForOrg(final long page, final long size) { return registrationApi.getAllForOrg(workspace.getConsumerOrgId(), page, size); } + + // Subscriber Filter implementations + + @Override + public Optional validateSubscriberFilter(String registrationId, SubscriberFilterValidationInputModel validationInput) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + if (validationInput == null) { + throw new IllegalArgumentException("validationInput cannot be null"); + } + return registrationApi.validateFilters(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, validationInput); + } + + @Override + public Optional createSubscriberFilter(String registrationId, CreateSubscriberFilterModel createSubscriberFilterModel) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + if (createSubscriberFilterModel == null) { + throw new IllegalArgumentException("createSubscriberFilterModel cannot be null"); + } + return registrationApi.createSubscriberFilter(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, createSubscriberFilterModel); + } + + @Override + public Optional> getAllSubscriberFilters(String registrationId) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + return registrationApi.getAllSubscriberFilters(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId); + } + + @Override + public Optional getSubscriberFilterById(String registrationId, UUID subscriberFilterId) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + if (subscriberFilterId == null) { + throw new IllegalArgumentException("subscriberFilterId cannot be null"); + } + return registrationApi.getSubscriberFilterById(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, subscriberFilterId); + } + + @Override + public Optional updateSubscriberFilter(String registrationId, UUID subscriberFilterId, CreateSubscriberFilterModel updateSubscriberFilterModel) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + if (subscriberFilterId == null) { + throw new IllegalArgumentException("subscriberFilterId cannot be null"); + } + if (updateSubscriberFilterModel == null) { + throw new IllegalArgumentException("updateSubscriberFilterModel cannot be null"); + } + return registrationApi.updateSubscriberFilter(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, subscriberFilterId, updateSubscriberFilterModel); + } + + @Override + public void deleteSubscriberFilter(String registrationId, UUID subscriberFilterId) { + if (StringUtils.isEmpty(registrationId)) { + throw new IllegalArgumentException("registrationId cannot be null or empty"); + } + if (subscriberFilterId == null) { + throw new IllegalArgumentException("subscriberFilterId cannot be null"); + } + registrationApi.deleteSubscriberFilter(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, subscriberFilterId); + } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CreateSubscriberFilterModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CreateSubscriberFilterModel.java new file mode 100644 index 00000000..346a0c65 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CreateSubscriberFilterModel.java @@ -0,0 +1,79 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +/** + * Model for creating a new subscriber filter. + * Contains the name, description, and filter definition for the subscriber filter. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateSubscriberFilterModel { + + @JsonProperty("name") + private final String name; + + @JsonProperty("description") + private final String description; + + @JsonProperty("subscriber_filter") + private final String subscriberFilter; + + @JsonCreator + public CreateSubscriberFilterModel( + @JsonProperty("name") String name, + @JsonProperty("description") String description, + @JsonProperty("subscriber_filter") String subscriberFilter) { + this.name = name; + this.description = description; + this.subscriberFilter = subscriberFilter; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getSubscriberFilter() { + return subscriberFilter; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CreateSubscriberFilterModel that = (CreateSubscriberFilterModel) o; + return Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(subscriberFilter, that.subscriberFilter); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, subscriberFilter); + } + + @Override + public String toString() { + return "CreateSubscriberFilterModel{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CustomSampleEventModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CustomSampleEventModel.java new file mode 100644 index 00000000..be116b54 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/CustomSampleEventModel.java @@ -0,0 +1,64 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import java.util.Objects; + +/** + * Model representing a custom sample event used for subscriber filter validation. + * Contains a sample payload and a name for identification. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class CustomSampleEventModel { + + @JsonProperty("sample_payload") + private final JsonNode samplePayload; + + @JsonProperty("name") + private final String name; + + public CustomSampleEventModel(JsonNode samplePayload, String name) { + this.samplePayload = samplePayload; + this.name = name; + } + + public JsonNode getSamplePayload() { + return samplePayload; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CustomSampleEventModel that = (CustomSampleEventModel) o; + return Objects.equals(samplePayload, that.samplePayload) && Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(samplePayload, name); + } + + @Override + public String toString() { + return "CustomSampleEventModel{" + "name='" + name + '\'' + '}'; + } +} \ No newline at end of file diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventMetadataIdOutputModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventMetadataIdOutputModel.java new file mode 100644 index 00000000..9d0a0a0f --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventMetadataIdOutputModel.java @@ -0,0 +1,66 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +/** + * Model representing event metadata ID output. + * Contains the event code and provider ID to uniquely identify an event. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventMetadataIdOutputModel { + + @JsonProperty("event_code") + private final String eventCode; + + @JsonProperty("provider_id") + private final String providerId; + + public EventMetadataIdOutputModel(String eventCode, String providerId) { + this.eventCode = eventCode; + this.providerId = providerId; + } + + public String getEventCode() { + return eventCode; + } + + public String getProviderId() { + return providerId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EventMetadataIdOutputModel that = (EventMetadataIdOutputModel) o; + return Objects.equals(eventCode, that.eventCode) && Objects.equals(providerId, that.providerId); + } + + @Override + public int hashCode() { + return Objects.hash(eventCode, providerId); + } + + @Override + public String toString() { + return "EventMetadataIdOutputModel{" + + "eventCode='" + eventCode + '\'' + + ", providerId='" + providerId + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java index 09957770..0e969b1f 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java @@ -81,6 +81,9 @@ public class Registration { @JsonProperty("events_of_interest") private final Set eventsOfInterests; + @JsonProperty("subscriber_filters") + private final Set subscriberFilters; + @JsonCreator public Registration( @JsonProperty("id") Long id, @@ -98,7 +101,8 @@ public Registration( @JsonProperty("webhook_url") String webhookUrl, @JsonProperty("runtime_action") String runtimeAction, @JsonProperty("enabled") boolean enabled, - @JsonProperty("events_of_interest") Set eventsOfInterests) { + @JsonProperty("events_of_interest") Set eventsOfInterests, + @JsonProperty("subscriber_filters") Set subscriberFilters) { this.id = id; this.name = name; this.description = description; @@ -115,6 +119,7 @@ public Registration( this.runtimeAction = runtimeAction; this.enabled = enabled; this.eventsOfInterests = eventsOfInterests; + this.subscriberFilters = subscriberFilters; this.self = self; this.traceUrl = traceUrl; this.journalUrl = journalUrl; @@ -198,6 +203,10 @@ public Set getEventsOfInterests() { return eventsOfInterests; } + public Set getSubscriberFilters() { + return subscriberFilters; + } + @Override public boolean equals(Object o) { if (this == o) { return true; @@ -224,12 +233,13 @@ public Set getEventsOfInterests() { Objects.equals(workspaceId, that.workspaceId) && Objects.equals(webhookUrl, that.webhookUrl) && Objects.equals(runtimeAction, that.runtimeAction) && - Objects.equals(eventsOfInterests, that.eventsOfInterests); + Objects.equals(eventsOfInterests, that.eventsOfInterests) && + Objects.equals(subscriberFilters, that.subscriberFilters); } @Override public int hashCode() { return Objects.hash(self, journalUrl, traceUrl, id, name, description, clientId, registrationId, deliveryType, webhookStatus, - createdDate, updatedDate, consumerId, projectId, workspaceId, webhookUrl, runtimeAction, enabled, eventsOfInterests); + createdDate, updatedDate, consumerId, projectId, workspaceId, webhookUrl, runtimeAction, enabled, eventsOfInterests, subscriberFilters); } @Override public String toString() { diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java index 22ec63d8..a655a711 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java @@ -30,8 +30,8 @@ public class RegistrationCreateModel extends RegistrationUpdateModel { private RegistrationCreateModel(final String clientId, final String name, final String description, final String deliveryType, final String runtimeAction, final Set eventsOfInterestInputModels, - final String webhookUrl, final boolean enabled) { - super(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled); + final String webhookUrl, final boolean enabled, final Set subscriberFilters) { + super(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled, subscriberFilters); if (StringUtils.isBlank(clientId)) { throw new IllegalArgumentException( "Registration is missing a clientId"); @@ -59,7 +59,7 @@ public String getClientId() { @Override public int hashCode() { - return Objects.hash(clientId, name, description, deliveryType, runtimeAction, eventsOfInterestInputModels, webhookUrl, enabled); + return Objects.hash(clientId, name, description, deliveryType, runtimeAction, eventsOfInterestInputModels, webhookUrl, enabled, subscriberFilters); } @Override @@ -73,6 +73,7 @@ public String toString() { ", eventsOfInterestInputModels=" + eventsOfInterestInputModels + ", webhookUrl='" + webhookUrl + '\'' + ", enabled='" + enabled + '\'' + + ", subscriberFilters=" + subscriberFilters + '}'; } @@ -93,7 +94,7 @@ public Builder clientId(String clientId) { @Override public RegistrationCreateModel build() { return new RegistrationCreateModel(clientId, name, description, deliveryType, runtimeAction, - eventsOfInterestInputModels, webhookUrl, enabled); + eventsOfInterestInputModels, webhookUrl, enabled, subscriberFilters); } } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java index a5e67a4b..9ad14749 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java @@ -44,9 +44,13 @@ public class RegistrationUpdateModel { @JsonProperty("enabled") protected Boolean enabled; + @JsonProperty("subscriber_filters") + protected Set subscriberFilters; + RegistrationUpdateModel(final String name, final String description, final String webhookUrl, final Set eventsOfInterestInputModels, final String deliveryType, - final String runtimeAction, final Boolean enabled) { + final String runtimeAction, final Boolean enabled, + final Set subscriberFilters) { if (StringUtils.isBlank(name)){ throw new IllegalArgumentException("Registration is missing a name"); @@ -71,6 +75,7 @@ public class RegistrationUpdateModel { this.deliveryType = deliveryType; this.runtimeAction = runtimeAction; this.enabled = enabled == null || enabled; + this.subscriberFilters = subscriberFilters; } public String getName() { @@ -101,6 +106,11 @@ public String getRuntimeAction() { return runtimeAction; } + + public Set getSubscriberFilters() { + return subscriberFilters; + } + @Override public boolean equals(Object o) { if (this == o) { return true; @@ -115,12 +125,13 @@ public String getRuntimeAction() { Objects.equals(eventsOfInterestInputModels, that.eventsOfInterestInputModels) && Objects.equals(deliveryType, that.deliveryType) && Objects.equals(runtimeAction, that.runtimeAction) && - Objects.equals(enabled, that.enabled); + Objects.equals(enabled, that.enabled) && + Objects.equals(subscriberFilters, that.subscriberFilters); } @Override public int hashCode() { - return Objects.hash(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled); + return Objects.hash(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, enabled, subscriberFilters); } @Override @@ -133,6 +144,7 @@ public String toString() { ", deliveryType=" + deliveryType + ", runtimeAction=" + runtimeAction + ", enabled='" + enabled + '\'' + + ", subscriberFilters=" + subscriberFilters + '}'; } @@ -150,6 +162,7 @@ public static class Builder { protected Set eventsOfInterestInputModels = new HashSet<>(); protected String webhookUrl; protected Boolean enabled = Boolean.TRUE; + protected Set subscriberFilters = new HashSet<>(); public Builder() { } @@ -196,10 +209,25 @@ public T enabled(Boolean enabled) { return (T) this; } + public T addSubscriberFilter(CreateSubscriberFilterModel subscriberFilter) { + this.subscriberFilters.add(subscriberFilter); + return (T) this; + } + + public T addSubscriberFilters(Set subscriberFilters) { + this.subscriberFilters.addAll(subscriberFilters); + return (T) this; + } + + public T subscriberFilters(Set subscriberFilters) { + this.subscriberFilters = subscriberFilters != null ? subscriberFilters : new HashSet<>(); + return (T) this; + } + public RegistrationUpdateModel build() { return new RegistrationUpdateModel(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, runtimeAction, - enabled); + enabled, subscriberFilters); } } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterModel.java new file mode 100644 index 00000000..01a1f949 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterModel.java @@ -0,0 +1,64 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.UUID; + +/** + * Model representing a subscriber filter with an ID. + * Extends CreateSubscriberFilterModel to include the unique identifier. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SubscriberFilterModel extends CreateSubscriberFilterModel { + + @JsonProperty("id") + private final UUID id; + + @JsonCreator + public SubscriberFilterModel( + @JsonProperty("id") UUID id, + @JsonProperty("name") String name, + @JsonProperty("description") String description, + @JsonProperty("subscriber_filter") String subscriberFilter) { + super(name, description, subscriberFilter); + this.id = id; + } + + public UUID getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + SubscriberFilterModel that = (SubscriberFilterModel) o; + return Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), id); + } + + @Override + public String toString() { + return "SubscriberFilterModel{" + "id=" + id + '}'; + } +} \ No newline at end of file diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationInputModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationInputModel.java new file mode 100644 index 00000000..dce0d598 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationInputModel.java @@ -0,0 +1,69 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.Set; + +/** + * Model for validating subscriber filters. + * Contains the subscriber filter to validate and optional custom sample events. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SubscriberFilterValidationInputModel { + + @JsonProperty("subscriber_filter") + private final SubscriberFilterModel subscriberFilter; + + @JsonProperty("custom_sample_events") + private final Set customSampleEventModels; + + public SubscriberFilterValidationInputModel( + SubscriberFilterModel subscriberFilter, + Set customSampleEventModels) { + this.subscriberFilter = subscriberFilter; + this.customSampleEventModels = customSampleEventModels; + } + + public SubscriberFilterModel getSubscriberFilter() { + return subscriberFilter; + } + + public Set getCustomSampleEventModels() { + return customSampleEventModels; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SubscriberFilterValidationInputModel that = (SubscriberFilterValidationInputModel) o; + return Objects.equals(subscriberFilter, that.subscriberFilter) && Objects.equals(customSampleEventModels, that.customSampleEventModels); + } + + @Override + public int hashCode() { + return Objects.hash(subscriberFilter, customSampleEventModels); + } + + @Override + public String toString() { + return "SubscriberFilterValidationInputModel{" + + "subscriberFilter=" + subscriberFilter + + ", customSampleEventModels=" + customSampleEventModels + + '}'; + } +} \ No newline at end of file diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationOutputModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationOutputModel.java new file mode 100644 index 00000000..6ca6151e --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/SubscriberFilterValidationOutputModel.java @@ -0,0 +1,115 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.Set; + +/** + * Model representing the output of subscriber filter validation. + * Contains the results of testing the filter against events of interest and custom sample events. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SubscriberFilterValidationOutputModel { + + @JsonProperty("accepted_event_metadata_ids") + private final Set acceptedEventMetadataIds; + + @JsonProperty("rejected_event_metadata_ids") + private final Set rejectedEventMetadataIds; + + @JsonProperty("unknown_event_metadata_ids") + private final Set unknownEventMetadataIds; + + @JsonProperty("accepted_custom_sample_events") + private final Set acceptedCustomSampleEvents; + + @JsonProperty("rejected_custom_sample_events") + private final Set rejectedCustomSampleEvents; + + @JsonProperty("invalid_custom_sample_events") + private final Set invalidCustomSampleEvents; + + public SubscriberFilterValidationOutputModel( + Set acceptedEventMetadataIds, + Set rejectedEventMetadataIds, + Set unknownEventMetadataIds, + Set acceptedCustomSampleEvents, + Set rejectedCustomSampleEvents, + Set invalidCustomSampleEvents) { + this.acceptedEventMetadataIds = acceptedEventMetadataIds; + this.rejectedEventMetadataIds = rejectedEventMetadataIds; + this.unknownEventMetadataIds = unknownEventMetadataIds; + this.acceptedCustomSampleEvents = acceptedCustomSampleEvents; + this.rejectedCustomSampleEvents = rejectedCustomSampleEvents; + this.invalidCustomSampleEvents = invalidCustomSampleEvents; + } + + public Set getAcceptedEventMetadataIds() { + return acceptedEventMetadataIds; + } + + public Set getRejectedEventMetadataIds() { + return rejectedEventMetadataIds; + } + + public Set getUnknownEventMetadataIds() { + return unknownEventMetadataIds; + } + + public Set getAcceptedCustomSampleEvents() { + return acceptedCustomSampleEvents; + } + + public Set getRejectedCustomSampleEvents() { + return rejectedCustomSampleEvents; + } + + public Set getInvalidCustomSampleEvents() { + return invalidCustomSampleEvents; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SubscriberFilterValidationOutputModel that = (SubscriberFilterValidationOutputModel) o; + return Objects.equals(acceptedEventMetadataIds, that.acceptedEventMetadataIds) && + Objects.equals(rejectedEventMetadataIds, that.rejectedEventMetadataIds) && + Objects.equals(unknownEventMetadataIds, that.unknownEventMetadataIds) && + Objects.equals(acceptedCustomSampleEvents, that.acceptedCustomSampleEvents) && + Objects.equals(rejectedCustomSampleEvents, that.rejectedCustomSampleEvents) && + Objects.equals(invalidCustomSampleEvents, that.invalidCustomSampleEvents); + } + + @Override + public int hashCode() { + return Objects.hash(acceptedEventMetadataIds, rejectedEventMetadataIds, unknownEventMetadataIds, + acceptedCustomSampleEvents, rejectedCustomSampleEvents, invalidCustomSampleEvents); + } + + @Override + public String toString() { + return "SubscriberFilterValidationOutputModel{" + + "acceptedEventMetadataIds=" + acceptedEventMetadataIds + + ", rejectedEventMetadataIds=" + rejectedEventMetadataIds + + ", unknownEventMetadataIds=" + unknownEventMetadataIds + + ", acceptedCustomSampleEvents=" + acceptedCustomSampleEvents + + ", rejectedCustomSampleEvents=" + rejectedCustomSampleEvents + + ", invalidCustomSampleEvents=" + invalidCustomSampleEvents + + '}'; + } +} \ No newline at end of file