Qlik NPrinting API Enablement Gianluca Perin NPrinting Product
Qlik NPrinting API Enablement Gianluca Perin – NPrinting Product Area Manager Aran Nathanson – Collaboration Product Manager September 2017
Agenda
Agenda • Introduction • Event Chaining • AD Sync • On-Demand • Q&A 3
Introduction
Tools To perform all the API calls during this training, we’ll rely on open-source Tools: Google Chrome and ARC client
Documentation In this training, we’ll use Qlik NPrinting and Qlik Sense public REST APIs. You can find extensive documentation on all the available APIs here: Qlik NPrinting: http: //help. qlik. com/en-US/NPrinting/June 2017/APIs/NP%20 API/ Qlik Sense: http: //help. qlik. com/en-US/sense-developer/June 2017/Content/APIs-and-SDKs. htm
Authentication ARC client relies on Chrome authentication session to log in to NPrinting and Sense.
Event Chaining
Event Chaining The purpose of this section is to show to create a full cycle of events, starting from the reload of a Sense App, going through NPrinting metadata reload and concluding with an NPrinting publish task.
Triggering a Sense App Reload - 1 To trigger the reload we will rely on Sense's QRS REST API. This is the easiest way to accomplish that. First, we need to identify which app we want to reload. In order to do that, we can get the list of all available Apps from Sense :
Triggering a Sense App Reload - 2 The App that we'll use for our reports is "Executive Dashboard“, but since we don't have the data needed to perform a reload data task, we'll use the "License Monitor" App. For the sake of our example, the result is the same. In order to trigger a reload data task for the "License Monitor" App, we need to use its id: "id": "74842 bbf-8 eb 7 -4158 -938 e-8142 d 865 c 10 e"
Triggering a Sense App Reload - 3 Now we want to know when the task is complete. In order to do that, we need to get the details of the specific App and check the "last. Reload. Time" parameter.
Triggering NPrinting Reload Metadata - 1 (September 2017) First we need to identify which connection we want to reload:
Triggering NPrinting Reload Metadata - 2 (September 2017) We need the "id" parameter in order to trigger the reload metadata task
Triggering NPrinting Reload Metadata - 3 (September 2017) Now we want to know when this reload metadata task is done. In order to do that, we need the connection id used to trigger the reload metadata task. We need to check the "cache. Status" parameter until it changes to "Generated" status
Triggering an NPrinting Publish Task – 1 (June 2017) First we need to identify which publish task we want to reload
Triggering an NPrinting Publish Task – 2 (June 2017) Now we can use the "id" parameter to trigger the publish task
Triggering an NPrinting Publish Task – 3 (June 2017) In order to understand when the task is done, we need to check this specific execution status. We need to use the "id" parameter returned by the previous call
AD Sync
AD Sync The purpose of this section is to explain how to use the AD-Sync tool created by the NPrinting team and how to customize it. We'll also show some of the API calls used inside this tool.
The Tool – 1 The AD-Sync tool is a C# project available in Git. Hub: https: //github. com/qlik-oss/NPrinting -adsync
The Tool – 2 This tool is composed of two main libraries: • ADSync. CSharp: C# Active Directory Synchronization library • NPrinting. Rest. Client: C# Rest client for NPrinting API The first library manages AD queries and data extraction. The second one manages communication with NPrinting through its REST APIs. You can use this tool out-of-the-box or you can customize it in order to better fit your needs.
How to use the tool - introduction First, you need to make sure that the domain user that you'll use to run the tool is also an NPrinting user with the Administrator Role. Alternatevly, you need to assign to the domain user full privileges for Users and Groups and only ”View” and “Edit” privilege for Security.
How to use the tool - introduction Also you need to consider that, for security reasons, with this tool (i. e. with NPrinting APIs) you can create Groups, Users and associate them with NPrinting roles, but you cannot create NPrinting roles. These roles must be created manually in the NPrinting Web Console.
How to use the tool - configuration Once you have downloaded and extracted the project, you will end up with a folder called: NPrinting-adsync-master Inside this folder you should see the following folder tree:
How to use the tool - configuration Go to: . srcADSync. Demo. App and open the file adsync. NPrinting. config Here you'll see two sections: Active Directory Configuration and NPrinting Configuration
How to use the tool - configuration In the first section, these are the available configuration parameters: • "url": The Active Directory server IP and Port • "domain. Name": The name of the Active Directory domain • "root. DN": The root of the Active Directory tree to be synched with NPrinting • "sync. Base. DN": The domain controller name to be synched with NPrinting • "search. Filter": The filter that will be applied to groups to be synched with NPrinting. By default the tool will scan all the groups that start with "NP" • "search. Deleted. Objects. Filter": The filter that will be applied to objects to be deleted. By default the tool will search for deleted groups that were placed under the specified "root. DN". In the second section, there is only one available configuration parameter: • "np. Url": The NPrinting url composed of IP and Port Once you’ve configured the tool with the desired settings, you can proceed with the actual tool building.
How to use the tool - building Under the root folder of the project (NPrinting-adsyncmaster) youll find a. bat script called: build. bat Run it inside a command prompt shell
How to use the tool - building Now go to . srcADSync. Demo. Appbuild Here you'll find a file called "ADSync. Demo. App. exe".
How to use the tool - run The first time that you run the tool, it will perform a full scan of the AD tree specified in the configuration file, creating all the users and groups that fit the configured search filter. In this Demo environment, we have the following groups:
How to use the tool - run Now run the tool, specifying in the command line the AD bind user and password (this bind user must obviously have permission to navigate the AD tree and also to access the AD trash bin in order to identify deleted groups). In the command prompt type: ADSync. Demo. App. exe --u domainuser --p password Where domainuser is the bind username and password is the bind password.
How to use the tool - run The next executions will perform an incremental sync, considering only new or deleted objects. This control is done by keeping track of the last execution timestamp in the following file: . srcADSync. Demo. AppbuildAd. Sync. Highest. Committed. USN. txt If you want to perform a full sync again, simply delete it.
How to use the tool - run As expected, all the compliant groups are imported in NPrinting, with all their members associated with the right roles:
API Details Let's take a look at the APIs used by this tool. Say that we want to create a new group called NP_Another_Group And give all its members the Newsstand User role. Inside this group we'll create two users: User. A with email "usera@qlik. com" and User. B with email "userb@qlik. com"
API Details First, we need to check if such a group already exists:
API Details This group doesn't exist so we can create it:
API Details Now let's check if the two users that we want to create already exist (you’ll need to repeat this for User. B using the same procedure):
API Details These users don't exist so we can create them (repeat the same procedure for User. B):
API Details Now that the users have been created, we can associate them with NP_Another_Group which we created in previous steps (For User. B the procedure is the same) In order to do that, we need the user ID and the group ID:
API Details The last step is to give the users the "Newsstand User" role. In order to do that, we need the user ID and the role ID:
API Details We're done! Now we can check the results in the NPrinting Web Console.
On-Demand
On-Demand - Introduction The purpose of this section is to show easy it is to perform a Sense based on-demand report with selections applied.
On-Demand - Retrieving Connection and Report ID In order to perform an ondemand request, we need to get the report connection:
On-Demand - Retrieving Connection and Report ID With this call, we retrieved the connection id. We'll now do the same thing for reports:
On-Demand - Retrieving Connection and Report ID Now we can create the actual on-demand request.
Triggering an On-Demand request with selection applied (June 2017) This specific API is available starting from the June 2017 release. In order to create an On-Demand request, we need to have the Connection ID, Report ID and selections that we want to apply. In this case we want to filter for the Sense field called "Product Sub Group Desc", with the following field values: "Bologna" and "Sugar":
Triggering an On-Demand request with selection applied (June 2017) With this specific execution ID, we can monitor the status of this ondemand request:
Triggering an On-Demand request with selection applied (June 2017) Once the "status" parameter is "completed", we can proceed to download the actual report file for the same execution id:
Triggering an On-Demand request with selection applied (June 2017) We're done! We can copy and paste the above URL into a browser with an open NPrinting session in order to download the actual file.
Q&A
Thank you!
- Slides: 52