Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
micahsakata
Contributor III
Contributor III

What space am I in?

In Qlik Cloud, there are no separate environments for dev/qa/prod.  These just exist as spaces in the tenant.  I found documentation with some guidance.

https://community.qlik.com/t5/Design/Managing-your-Analytics-lifecycle-in-Qlik-Sense-Enterprise-SaaS...

In this post, there is also a video saying that you can create script to determine what space you are in.

https://community.qlik.com/t5/Design/Systems-Development-Lifecycle-SDLC-with-the-Qlik-Active/ba-p/19...

I cannot find any documentation on how to create the rest connector to access this information.  We did our best to create the rest connection but in doing so, we had to create an API key.  This has an expiration attached to the API key.  This can't be the case for code that will be used every day.  I don't think this is reasonable.  Given that this is a solution that Qlik is suggesting, what is the right solution to this?

Labels (1)
  • Cloud

1 Solution

Accepted Solutions
JonnyPoole
Former Employee
Former Employee

The GetSysAttr() function allows you to see a lot of Cloud specific metadata such as tenant, space etc...

 

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemFunction...

 

JonnyPoole_0-1710276756287.png

 

View solution in original post

6 Replies
Daniele_Purrone
Support
Support

Hi @micahsakata,

the only way I could find is to, indeed, use the Rest connector, providing the API's key in the headers.

In a space called Shared you can create a connection to https://TN.RG.qlikcloud.com/api/v1/apps   called REST_Apps and one called REST_space to https://TN.RG.qlikcloud.com/api/v1/spaces   

Daniele_Purrone_0-1710233529835.png

 

 

 

LIB CONNECT TO 'Shared:REST_Apps';


RestConnectorMasterTable:
SQL SELECT 
	"__KEY_root",
	(SELECT 
		"__FK_data",
		"__KEY_data",
		(SELECT 
			"id",
			"spaceId",
			"__FK_attributes",
			"__KEY_attributes"
		FROM "attributes" PK "__KEY_attributes" FK "__FK_attributes")
	FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root";

[attributes]:
LOAD	[id],
	[spaceId]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_attributes]);


DROP TABLE RestConnectorMasterTable;

LIB CONNECT TO 'Shared:REST_spaces';


RestConnectorMasterTable:
SQL SELECT 
	"__KEY_root",
	(SELECT 
		"id",
		"name",
		"__FK_data",
		"__KEY_data"
	FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root";

[data]:
LOAD	[id] as [spaceId],
	[name]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_data]);


DROP TABLE RestConnectorMasterTable;

 

 

Then compare that to the current appId accessible via DocumentName()

And yes, APIs will expire at some point, but you can set the expiration date a long way in the future.

Maybe @Leigh_Kennedy who created the video has some better tips.

If you think it would be useful to add a SpaceName() function, please, log an idea, so that we can gather consensus around it.

Daniele - Principal Technical Support Engineer & SaaS Support Coordinator at Qlik
If a post helps to resolve your issue, please accept it as a Solution.
micahsakata
Contributor III
Contributor III
Author

I'm seeing the expiration for a new API key is either "6 hours" or "a day".  Again, if this solution from the posts are being touted as a way to navigate your environments, there is no way I can be expected to update that data connection daily.  Am I missing something?

JonnyPoole
Former Employee
Former Employee

The GetSysAttr() function allows you to see a lot of Cloud specific metadata such as tenant, space etc...

 

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemFunction...

 

JonnyPoole_0-1710276756287.png

 

Leigh_Kennedy
Employee
Employee

As Jonny says, GetSysAttr() is the way to do it now (it didn't exist when I prepared that material).  I have an updated version of that paper almost ready to release.

Daniele_Purrone
Support
Support

Thanks @JonnyPoole !
I had missed that, this settles it!

Daniele - Principal Technical Support Engineer & SaaS Support Coordinator at Qlik
If a post helps to resolve your issue, please accept it as a Solution.
Daniele_Purrone
Support
Support

Hi @micahsakata ,

you got the answer to your query from @JonnyPoole. When it comes to the API duration, the maximum default is indeed one day, but you can change that in the tenant's settings.

Daniele - Principal Technical Support Engineer & SaaS Support Coordinator at Qlik
If a post helps to resolve your issue, please accept it as a Solution.