takraj commented on code in PR #6504:
URL: https://github.com/apache/nifi/pull/6504#discussion_r995755730


##########
nifi-nar-bundles/nifi-asana-bundle/nifi-asana-services/src/main/java/org/apache/nifi/controller/asana/AsanaClientService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.controller.asana;
+
+import com.asana.Client;
+import com.google.common.collect.Lists;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.resource.ResourceCardinality;
+import org.apache.nifi.components.resource.ResourceType;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processor.util.StandardValidators;
+
+import java.util.Collections;
+import java.util.List;
+
+import static 
org.apache.nifi.controller.asana.AsanaClientImpl.ASANA_CLIENT_OPTION_BASE_URL;
+
+@CapabilityDescription("Common service to authenticate with Asana, and to work 
on a specified workspace.")
+@Tags({"asana", "service", "authentication"})
+public class AsanaClientService extends AbstractControllerService implements 
AsanaClientServiceApi {
+
+    protected static final String ASANA_API_URL = "asana-api-url";
+    protected static final String ASANA_PERSONAL_ACCESS_TOKEN = 
"asana-personal-access-token";
+    protected static final String ASANA_WORKSPACE_NAME = 
"asana-workspace-name";
+
+    protected static final PropertyDescriptor PROP_ASANA_API_BASE_URL = new 
PropertyDescriptor.Builder()
+            .name(ASANA_API_URL)
+            .displayName("API URL")
+            .description("Base URL of Asana API. Leave it as default, unless 
you have your own Asana instance "
+                    + "serving on a different URL. (typical for on-premise 
installations)")
+            .required(true)
+            
.defaultValue(Client.DEFAULTS.get(ASANA_CLIENT_OPTION_BASE_URL).toString())
+            .identifiesExternalResource(ResourceCardinality.SINGLE, 
ResourceType.URL)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_PERSONAL_ACCESS_TOKEN 
= new PropertyDescriptor.Builder()
+            .name(ASANA_PERSONAL_ACCESS_TOKEN)
+            .displayName("Personal Access Token")
+            .description("Similarly to entering your username/password into a 
website, when you access "
+                    + "your Asana data via the API you need to authenticate. 
Personal Access Token (PAT) "
+                    + "is an authentication mechanism for accessing the API. 
You can generate a PAT from "
+                    + "the Asana developer console. Refer to Asana 
Authentication Quick Start for detailed "
+                    + "instructions on getting started.")
+            .required(true)
+            .sensitive(true)
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_WORKSPACE_NAME = new 
PropertyDescriptor.Builder()
+            .name(ASANA_WORKSPACE_NAME)
+            .displayName("Workspace")
+            .description("Specify which Asana workspace to use. Case 
sensitive. "
+                    + "A workspace is the highest-level organizational unit in 
Asana. All projects and tasks "
+                    + "have an associated workspace. An organization is a 
special kind of workspace that "
+                    + "represents a company. In an organization, you can group 
your projects into teams.")
+            .required(true)
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .build();
+
+    protected static final List<PropertyDescriptor> DESCRIPTORS = 
Collections.unmodifiableList(Lists.newArrayList(
+            PROP_ASANA_API_BASE_URL,
+            PROP_ASANA_PERSONAL_ACCESS_TOKEN,
+            PROP_ASANA_WORKSPACE_NAME
+    ));
+
+    private String personalAccessToken;
+    private String workspaceName;
+    private String baseUrl;

Review Comment:
   Done in 
[dc2a050](https://github.com/apache/nifi/pull/6504/commits/dc2a050548a389d89181670371748af741eefd61)



##########
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")
+            .description("Fetch only objects in this project. Case sensitive.")
+            .required(true)
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .dependsOn(
+                PROP_ASANA_OBJECT_TYPE,
+                    AV_COLLECT_TASKS,
+                    AV_COLLECT_TASK_ATTACHMENTS,
+                    AV_COLLECT_PROJECT_MEMBERS,
+                    AV_COLLECT_STORIES,
+                    AV_COLLECT_PROJECT_STATUS_UPDATES,
+                    AV_COLLECT_PROJECT_STATUS_ATTACHMENTS,
+                    AV_COLLECT_PROJECT_EVENTS)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_SECTION = new 
PropertyDescriptor.Builder()
+            .name(ASANA_SECTION_NAME)
+            .displayName("Section name")
+            .description("Fetch only objects in this section. Case sensitive.")
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .dependsOn(PROP_ASANA_OBJECT_TYPE, AV_COLLECT_TASKS, 
AV_COLLECT_TASK_ATTACHMENTS, AV_COLLECT_STORIES)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_TAG = new 
PropertyDescriptor.Builder()
+            .name(ASANA_TAG_NAME)
+            .displayName("Tag")
+            .description("Fetch only objects having this tag. Case sensitive.")
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .dependsOn(PROP_ASANA_OBJECT_TYPE, AV_COLLECT_TASKS, 
AV_COLLECT_TASK_ATTACHMENTS, AV_COLLECT_STORIES)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_TEAM_NAME = new 
PropertyDescriptor.Builder()
+            .name(ASANA_TEAM_NAME)
+            .displayName("Team")
+            .description("Team name. Case sensitive.")
+            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .dependsOn(PROP_ASANA_OBJECT_TYPE, AV_COLLECT_TEAM_MEMBERS)
+            .build();
+
+    protected static final PropertyDescriptor PROP_ASANA_OUTPUT_BATCH_SIZE = 
new PropertyDescriptor.Builder()
+            .name(ASANA_OUTPUT_BATCH_SIZE)
+            .displayName("Output Batch Size")
+            .description("The number of output FlowFiles to queue before 
committing the process session. When set to zero, the session will be committed 
when all result set rows "
+                    + "have been processed and the output FlowFiles are ready 
for transfer to the downstream relationship. For large result sets, this can 
cause a large burst of FlowFiles "
+                    + "to be transferred at the end of processor execution. If 
this property is set, then when the specified number of FlowFiles are ready for 
transfer, then the session will "
+                    + "be committed, thus releasing the FlowFiles to the 
downstream relationship.")
+            .defaultValue("0")
+            .required(true)
+            .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR)
+            .build();
+
+    protected static final List<PropertyDescriptor> DESCRIPTORS = 
Collections.unmodifiableList(Lists.newArrayList(
+            PROP_ASANA_CONTROLLER_SERVICE,
+            PROP_ASANA_OBJECT_TYPE,
+            PROP_ASANA_PROJECT,
+            PROP_ASANA_SECTION,
+            PROP_ASANA_TEAM_NAME,
+            PROP_ASANA_TAG,
+            PROP_ASANA_OUTPUT_BATCH_SIZE
+    ));
+
+    protected static final Relationship REL_NEW = new Relationship.Builder()
+            .name(REL_NAME_NEW)
+            .description("Newly collected objects are routed to this 
relationship.")
+            .build();
+
+    protected static final Relationship REL_UPDATED = new 
Relationship.Builder()
+            .name(REL_NAME_UPDATED)
+            .description("Objects that have already been collected earlier, 
but were updated since, are routed to this relationship.")
+            .build();
+
+    protected static final Relationship REL_REMOVED = new 
Relationship.Builder()
+            .name(REL_NAME_REMOVED)
+            .description("Notification about deleted objects are routed to 
this relationship. "
+                    + "Flow files will not have any payload. IDs of the 
resources no longer exist "
+                    + "are carried by the asana.gid attribute of the generated 
FlowFiles.")
+            .build();
+
+    protected static final Set<Relationship> RELATIONSHIPS = 
Collections.unmodifiableSet(Sets.newHashSet(
+            REL_NEW,
+            REL_UPDATED,
+            REL_REMOVED
+    ));
+
+    final Scope STATE_STORAGE_SCOPE = Scope.LOCAL;

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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to