takraj commented on code in PR #6504: URL: https://github.com/apache/nifi/pull/6504#discussion_r995754281
########## nifi-nar-bundles/nifi-asana-bundle/nifi-asana-processors/src/main/java/org/apache/nifi/processors/asana/GetAsanaObject.java: ########## @@ -0,0 +1,430 @@ +/* + * 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.asana; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.apache.http.entity.ContentType; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.Stateful; +import org.apache.nifi.annotation.behavior.TriggerSerially; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.state.Scope; +import org.apache.nifi.components.state.StateMap; +import org.apache.nifi.controller.asana.AsanaClient; +import org.apache.nifi.controller.asana.AsanaClientServiceApi; +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 org.apache.nifi.processors.asana.utils.AsanaObject; +import org.apache.nifi.processors.asana.utils.AsanaObjectFetcher; +import org.apache.nifi.processors.asana.utils.AsanaProjectEventFetcher; +import org.apache.nifi.processors.asana.utils.AsanaProjectFetcher; +import org.apache.nifi.processors.asana.utils.AsanaProjectMembershipFetcher; +import org.apache.nifi.processors.asana.utils.AsanaProjectStatusAttachmentFetcher; +import org.apache.nifi.processors.asana.utils.AsanaProjectStatusFetcher; +import org.apache.nifi.processors.asana.utils.AsanaStoryFetcher; +import org.apache.nifi.processors.asana.utils.AsanaTagFetcher; +import org.apache.nifi.processors.asana.utils.AsanaTaskAttachmentFetcher; +import org.apache.nifi.processors.asana.utils.AsanaTaskFetcher; +import org.apache.nifi.processors.asana.utils.AsanaTeamFetcher; +import org.apache.nifi.processors.asana.utils.AsanaTeamMemberFetcher; +import org.apache.nifi.processors.asana.utils.AsanaUserFetcher; +import org.apache.nifi.reporting.InitializationException; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +@TriggerSerially +@Stateful(scopes = {Scope.LOCAL}, description = "Fingerprints of items in the last successful query are stored in order to enable incremental loading and change detection.") +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) +@WritesAttribute(attribute = GetAsanaObject.ASANA_GID, description = "Global ID of the object in Asana.") +@Tags({"asana", "source", "connector", "ingest"}) +@CapabilityDescription("This processor collects data from Asana") +public class GetAsanaObject extends AbstractProcessor { + + protected static final String ASANA_GID = "asana.gid"; + protected static final String AV_NAME_COLLECT_TASKS = "asana-collect-tasks"; + protected static final String AV_NAME_COLLECT_TASK_ATTACHMENTS = "asana-collect-task-attachments"; + protected static final String AV_NAME_COLLECT_PROJECTS = "asana-collect-projects"; + protected static final String AV_NAME_COLLECT_TAGS = "asana-collect-tags"; + protected static final String AV_NAME_COLLECT_USERS = "asana-collect-users"; + protected static final String AV_NAME_COLLECT_PROJECT_MEMBERS = "asana-collect-project-members"; + protected static final String AV_NAME_COLLECT_TEAMS = "asana-collect-teams"; + protected static final String AV_NAME_COLLECT_TEAM_MEMBERS = "asana-collect-team-members"; + protected static final String AV_NAME_COLLECT_STORIES = "asana-collect-stories"; + protected static final String AV_NAME_COLLECT_PROJECT_STATUS_UPDATES = "asana-collect-project-status-updates"; + protected static final String AV_NAME_COLLECT_PROJECT_STATUS_ATTACHMENTS = "asana-collect-project-status-attachments"; + protected static final String AV_NAME_COLLECT_PROJECT_EVENTS = "asana-collect-project-events"; + protected static final String ASANA_CONTROLLER_SERVICE = "asana-controller-service"; + protected static final String ASANA_OBJECT_TYPE = "asana-object-type"; + protected static final String ASANA_PROJECT_NAME = "asana-project-name"; + protected static final String ASANA_SECTION_NAME = "asana-section-name"; + protected static final String ASANA_TAG_NAME = "asana-tag-name"; + protected static final String ASANA_TEAM_NAME = "asana-team-name"; + protected static final String ASANA_OUTPUT_BATCH_SIZE = "asana-output-batch-size"; + protected static final String REL_NAME_NEW = "new"; + protected static final String REL_NAME_UPDATED = "updated"; + protected static final String REL_NAME_REMOVED = "removed"; + + protected static final AllowableValue AV_COLLECT_TASKS = new AllowableValue( + AV_NAME_COLLECT_TASKS, + "Tasks", + "Collect tasks matching to the specified conditions."); + + protected static final AllowableValue AV_COLLECT_TASK_ATTACHMENTS = new AllowableValue( + AV_NAME_COLLECT_TASK_ATTACHMENTS, + "Task attachments", + "Collect attached files of tasks matching to the specified conditions." + ); + + protected static final AllowableValue AV_COLLECT_PROJECTS = new AllowableValue( + AV_NAME_COLLECT_PROJECTS, + "Projects", + "Collect projects of the workspace." + ); + + protected static final AllowableValue AV_COLLECT_TAGS = new AllowableValue( + AV_NAME_COLLECT_TAGS, + "Tags", + "Collect tags of the workspace." + ); + + protected static final AllowableValue AV_COLLECT_USERS = new AllowableValue( + AV_NAME_COLLECT_USERS, + "Users", + "Collect users assigned to the workspace." + ); + + protected static final AllowableValue AV_COLLECT_PROJECT_MEMBERS = new AllowableValue( + AV_NAME_COLLECT_PROJECT_MEMBERS, + "Members of a project", + "Collect users assigned to the specified project." + ); + + protected static final AllowableValue AV_COLLECT_TEAMS = new AllowableValue( + AV_NAME_COLLECT_TEAMS, + "Teams", + "Collect teams of the workspace." + ); + + protected static final AllowableValue AV_COLLECT_TEAM_MEMBERS = new AllowableValue( + AV_NAME_COLLECT_TEAM_MEMBERS, + "Team members", + "Collect users assigned to the specified team." + ); + + protected static final AllowableValue AV_COLLECT_STORIES = new AllowableValue( + AV_NAME_COLLECT_STORIES, + "Stories of tasks", + "Collect stories (comments) of of tasks matching to the specified conditions." + ); + + protected static final AllowableValue AV_COLLECT_PROJECT_STATUS_UPDATES = new AllowableValue( + AV_NAME_COLLECT_PROJECT_STATUS_UPDATES, + "Status updates of a project", + "Collect status updates of the specified project." + ); + + protected static final AllowableValue AV_COLLECT_PROJECT_STATUS_ATTACHMENTS = new AllowableValue( + AV_NAME_COLLECT_PROJECT_STATUS_ATTACHMENTS, + "Attachments of status updates", + "Collect attached files of project status updates." + ); + + protected static final AllowableValue AV_COLLECT_PROJECT_EVENTS = new AllowableValue( + AV_NAME_COLLECT_PROJECT_EVENTS, + "Events of a project", + "Collect various events happening on the specified project and on its' tasks." + ); + + protected static final PropertyDescriptor PROP_ASANA_CONTROLLER_SERVICE = new PropertyDescriptor.Builder() + .name(ASANA_CONTROLLER_SERVICE) + .displayName("Controller service") + .description("Specify which controller service to use for accessing Asana.") + .required(true) + .identifiesControllerService(AsanaClientServiceApi.class) + .build(); + + protected static final PropertyDescriptor PROP_ASANA_OBJECT_TYPE = new PropertyDescriptor.Builder() + .name(ASANA_OBJECT_TYPE) + .displayName("Object type to be collected") + .description("Specify what kind of objects to be collected from Asana") + .required(true) + .allowableValues( + AV_COLLECT_TASKS, + AV_COLLECT_TASK_ATTACHMENTS, + AV_COLLECT_PROJECTS, + AV_COLLECT_TAGS, + AV_COLLECT_USERS, + AV_COLLECT_PROJECT_MEMBERS, + AV_COLLECT_TEAMS, + AV_COLLECT_TEAM_MEMBERS, + AV_COLLECT_STORIES, + AV_COLLECT_PROJECT_STATUS_UPDATES, + AV_COLLECT_PROJECT_STATUS_ATTACHMENTS, + AV_COLLECT_PROJECT_EVENTS) + .defaultValue(AV_COLLECT_TASKS.getValue()) + .build(); + + protected static final PropertyDescriptor PROP_ASANA_PROJECT = new PropertyDescriptor.Builder() + .name(ASANA_PROJECT_NAME) + .displayName("Project name") Review Comment: Done in [dc2a050](https://github.com/apache/nifi/pull/6504/commits/dc2a050548a389d89181670371748af741eefd61) -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org