Closed simonaubertbd closed 2 years ago
Not that I want to take the spotlight away from Antony's awesome tool, but I would go to the official qlik cli tool for that.
Works really well with QSEoW/client-managed Sense too (at least for anything repository related, which includes reload tasks)
I am using it extensively with JWT auth-enabled virtual proxies in QSEoW, using PowerShell or Linux/macOS bash scripts to drive all kinds of automation and bulk tasks against QSEoW clusters.
Btw, PowerShell on macOS works really well these days. Never thought I'd experience that, but it's good to be proven wrong every now and then :)
...and if you need to create JWTs for use with QSEoW or Qlik Sense Cloud, qs-jwt has you covered.
https://github.com/ptarmiganlabs/qs-jwt
Short intro here.
For bulk renaming, you may find it easier to leverage the underlying PUT commands as there are some properties that are not exposed in the PowerShell functions
To update a Reload task we would use the API put /reloadtask/{id} providing a json string representing a Reload Task as the body, which we can get from the function Get-QlikReloadTask -raw -full
similar can be performed for most objects in Qlik Sense put /app/{id} put /stream/{id} put /contentlibrary/{id} put /schemaevent/{id} (Triggers)
Both options below perform exactly the same process, Option 1 is just very concise using shorthand, Option 2 is a little more verbose with comments
At its most basic this could look like this.
#Option 1
$QlikTasks = Get-QlikReloadTask -full -raw
$QlikTasks|%{$_.name = "Appended-$($_.name)"; Invoke-QlikPut "/qrs/reloadtask/$($_.id)" -body $($_|ConvertTo-Json -Depth 10) }
#Option 2
#Get all Tasks from QRS API (Returns an Array of task Objects)
$QlikTasks = Get-QlikReloadTask -full -raw
#Foreach task object in the Array of tasks returned from the previous command
foreach ($Task in $QlikTasks){
#Set the new name value
$TaskNewName = "Appended-$($Task.name)"
#Update the local object with the new name
$Task.name = $TaskNewName
#Convert the local PowerShell object to a json string
$TaskJson = $($Task|ConvertTo-Json -Depth 10)
#Pass the Json string to the QRS API
Invoke-QlikPut "/qrs/reloadtask/$($Task.id)" -body $TaskJson
}
for single objects you could use something like this
$SingleStream = Get-QlikStream -id aaa3d758-aaa2-aaa0-aaab-4e5e59291aaa -raw
## Make changes to the local object
$SingleStream
#update the QRS with the changes
Invoke-QlikPut -path "/qrs/stream/$($SingleStream.id)" -body $($SingleStream|ConvertTo-Json)
When using Get APIs that do not have a Function ensure to set $rawOutput = $true
as this will prevent the dates from being converted which may causes a 400
when doing the update
$rawOutput = $true
$SchemaEvents = Invoke-QlikGet "/qrs/SchemaEvent/Full"
foreach ($SchemaEvent in $SchemaEvents){
$NewSchemaEventName = "Append-$($SchemaEvent.name)"
$SchemaEvent.name = $NewSchemaEventName
$SchemaEventJson = $($SchemaEvent|ConvertTo-Json -Depth 20)
Invoke-QlikPut "/qrs/SchemaEvent/$($SchemaEvent.id)" -body $SchemaEventJson
}
Well, I used the update of task function.. and had to edit it. I close this ticket and will open two new.
Thanks to all.
@mountaindude I tried qlik cli official tool (with the .exe) but I have a certificate issue and was unable to deal with it for now. I also have to write a ticket on that point
@Nillth : thanks a lot. to be honest, i edited the qlik cli task.ps1 in resources
Best regards,
Simon
Hello,
I would like to bulk rename my task throuh qlik cli. However, it doesn't seem to be allowed. Can this functionnality be added (also for triggers, apps, stream, content library, etc)?
Best regards,
Simon