pvillard31 commented on code in PR #9777: URL: https://github.com/apache/nifi/pull/9777#discussion_r1983406154
########## nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/ConsumeBoxEnterpriseEvents.java: ########## @@ -0,0 +1,251 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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 CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.box; + +import com.box.sdk.BoxAPIConnection; +import com.box.sdk.BoxEvent; +import com.box.sdk.EnterpriseEventsStreamRequest; +import com.box.sdk.EventLog; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.PrimaryNodeOnly; +import org.apache.nifi.annotation.behavior.Stateful; +import org.apache.nifi.annotation.behavior.TriggerSerially; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.box.controllerservices.BoxClientService; +import org.apache.nifi.components.DescribedValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.state.Scope; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.flowfile.attributes.CoreAttributes; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import static org.apache.nifi.annotation.behavior.InputRequirement.Requirement.INPUT_FORBIDDEN; + +@PrimaryNodeOnly +@TriggerSerially +@Tags({"box", "storage"}) +@CapabilityDescription(""" + Consumes Enterprise Events from Box admin_logs_streaming Stream Type. + The content of the events is sent to the 'success' relationship as a JSON array. + The last known position of the Box stream is stored in the processor state and is used to + resume the stream from the last known position when the processor is restarted. + """) +@SeeAlso({ ConsumeBoxEvents.class, FetchBoxFile.class, ListBoxFile.class }) +@InputRequirement(INPUT_FORBIDDEN) +@Stateful(description = """ + The last known position of the Box Event stream is stored in the processor state and is used to + resume the stream from the last known position when the processor is restarted. + """, scopes = { Scope.CLUSTER }) +public class ConsumeBoxEnterpriseEvents extends AbstractProcessor { + + private static final String POSITION_KEY = "position"; + private static final String EARLIEST_POSITION = "0"; + private static final String LATEST_POSITION = "now"; + + private static final int LIMIT = 500; + + static final PropertyDescriptor EVENT_TYPES = new PropertyDescriptor.Builder() + .name("Event Types") + .description("A comma separated list of Enterprise Events to consume. If not set, all Events are consumed." + + "See Additional Details for more information.") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); Review Comment: Is it worth overriding customValidate to confirm that the configured list of event types is correct? (using the EventType enum) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
