How we we update the parent_id of a workspace. We ...
# gooddata-cloud
d
How we we update the parent_id of a workspace. We need to move some of our workspaces around to restructure https://www.gooddata.com/docs/python-sdk/latest/workspace/workspaces/create_or_update/
m
Hi Doug, unfortunately you cannot update a workspace’s
id
property or its parent workspace. In this case, you will need to recreate the workspace under the new parent workspace. May I know what's the use case?
d
We are reorganizing our customers, Splitting them in by Partner Space. Currently they are in 1 and we need to split them into two sub spaces Parent Sub Partent 1 | Sub Parent 2 Customer1 Customer3 Customer2. Customer4
Currently Parent Customer 1 customer 2 Customer 3 Customer 4
@Moises Morales whats the best way to make this transfer
m
Thank you for sharing your use case. In this case, I would recommend exporting the LDM of the original parent workspace into the new parent workspace in order to recreate the child under this new parent. Please note that as stated previously, modifying a child workspace's parent ID is not an option at the moment.
The export of your LDM can be done from the UI and can be imported into the child workspace by placing the LDM in edit mode:
d
I know its not possible to switch the partent Hmm, that will not work 100%, I need the metrics too So I'm pulling the declarative workspace and the workspace. Recreating the workspace - different ID. Then I need to push both the LDM and metrics. However, in metrics will it be just the custom ones or ALL, do I need to delete the overlap with the parent?
m
Your assumption is correct, the metrics would need to be recreated including the custom ones, in such case, you should be able to easily get the metric definitions from the old parent workspace via the API by doing a GET to the endpoint /api/v1/entities/workspaces/{workspaceId}/metrics. You can then use the body result to recreate them in the new child workspace by doing a POST to the same endpoint, more details about the expected body can be found in our API documentation here: https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/createEntity@Metrics
d
Yes, I already did that, what about permissions etc... How do we copy those over?
I am using the SDK by the way, its a bit easier for this as the API you would have to do Metrcs one at at ime
🙌 1
m
WDF (workspace data filters) are part of the LDM, they should carry over and work as expected as long as they are recreated using the same ID's. In any case, since this is sensitive security feature, I recommend double checking this, I haven't had time to test this myself.
d
Yes I will check that part. However, there is also user permissions etc. Is there anything else I'm forgetting about
Whats the differenence between workspace_id and id. Which one can I update without creating a new workspace?
m
User Data Permissions are set a bit differently, You can check if there are any set in the child workspace via this endpoint /api/v1/entities/workspaces/<workspace-id>/userDataFilters/. All in all, WDF and UDF are the two security features that we offer and that will have to recreated in your new workspaces as needed. I recommend checking the differences between the two outlined in our documentation here.
May I know where are you seeing "id"? "workspace_id" is used as a "placeholder" in our documentation and API, you need to replace it with your actual workspace id, usually an alphanumeric string, or you can also give a meaningful id to your workspace, for example "parent_wk".
d
Is there an API way for me to add and remove what groups a user is added to? Basically I want to remove "customer-453" and replace with "customer-453-2"
From your API. I guess ID is old
I suppose I just have to do that with the group
Just add a new workspace, and remove the other one
m
You can get the groups a user is added to via this API: GET
https://{hostname}/api/v1/entities/users/user_ID?include=userGroups
And then remove the old user group and add the new one with a PUT to this API:
https://{hostname}/api/v1/entities/users/user_ID?include=userGroups
Please make sure to add
Content-Type : application/vnd.gooddata.api+json
as the API header.
d
only API not SDK?
m
Regarding the id, thanks for clarifying. That's the data filter ID, not the workspace id, it may or may not share the same name/id as the workspace id:
d
is that related to the WDF filter?
I don't understand what the filter id is? I tried modifying the id: to be the same as the old one and a different workspace id and I got the error that its I can't update the parent (meaning this ID is referring to the old workspace).
I suspect that the ID here is NOT the filter ID. as I'm doing a workspace call and your API its a workspaceFilter call - two very different things
m
In that case, yes the screenshot I sent previously is related to WDFs, but I noticed you are rather calling
Copy code
workspace = sdk.catalog_workspace.get_workspace(workspace_id="123")
in the SDK. The error you are getting is mentioned here: https://www.gooddata.com/docs/python-sdk/latest/workspace/workspaces/create_or_update/ and it relates to the id of the workspace itself. This cannot be updated.
d
Ok, so the WDF filter DID not transfer. How do I set it with the SDK
ah here
m
The necessary steps can be found in our documentation here: https://www.gooddata.com/docs/python-sdk/latest/workspace/workspace-data-filters/