VMware Cloud Community
bdamian
Expert
Expert
Jump to solution

Export and import event-broker workflow subscriptions

Hi All,

Is there any way to export and import Subscriptions? I saw that with the Cloud Client you can export and import workflows and properties, but no subscriptions.

I've been able to get the subscriptions from the API but I can't update it or create a new one.

Any ideas?

Thanks.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
jasnyder
Hot Shot
Hot Shot
Jump to solution

I tested this and didn't have any problems with it.  In my setup, I am logged in as a user federated from an Active Directory into a tenant named 'MTD'

I can do these no problems:

GET /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions to see list of subscriptions

GET /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions/d449c824-2262-4e5f-a397-7d1b4d9ac822 to see a specific subscription.  From that I receive:

{"id":"d449c824-2262-4e5f-a397-7d1b4d9ac822","eventTopicId":"com.vmware.csp.component.cafe.composition.component.completed","workflowId":"bcbcc2cf-abeb-4f19-a835-f66c3641018c","tenantId":"MTD","name":"Send Custom Activation E-mail","blocking":false,"reply":false,"status":"DRAFT","statusName":"Draft","criteria":null,"version":{"version":"0.0.0","major":0,"minor":0,"micro":0,"revision":null},"description":"","priority":10,"timeout":null}

Reuse the JSON gotten from there, but strip out the ID and change the name (by adding a '2' on the end):

{"eventTopicId":"com.vmware.csp.component.cafe.composition.component.completed","workflowId":"bcbcc2cf-abeb-4f19-a835-f66c3641018c","tenantId":"MTD","name":"Send Custom Activation E-mail 2","blocking":false,"reply":false,"status":"DRAFT","statusName":"Draft","criteria":null,"version":{"version":"0.0.0","major":0,"minor":0,"micro":0,"revision":null},"description":"","priority":10,"timeout":null}

POST that JSON back to /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions/ and I get a HTTP 201 response and the subscription is created and shows up in the portal.

If I'm following what you want to do correctly, it seems that this works as intended.  Note that the user I am logged in with is a tenant administrator in the MTD tenant and has all of the roles assigned on the user account from within the Administration/Users & Groups area in the portal.  So maybe it's something to do with the account itself?

In my setup, administrator@vsphere.local does not have access to the tenant so I did not test with that account.

EDIT: just wanted to clarify this was tested on vRA 7.2.

EDIT2: I went back and re-read your post, and I think your issue might be that your POSTing and/or PUTting back to the subscription ID, but within the wrong tenant.

I can do a PUT to /api/tenants/MTD/event-broker/subscriptions/d449c824-2262-4e5f-a397-7d1b4d9ac822 using the original JSON (i.e. modifying it with no changes made) and I get an HTTP 204 response.  But if I modify the tenant in the JSON to "vsphere.local" instead of "MTD" I get an HTTP 400 with error similar to the one you saw:

{"errors":[{"code":85094,"message":"TenantId 'vsphere.local' of subscription 'd449c824-2262-4e5f-a397-7d1b4d9ac822' does not match the provided in the URL path 'MTD'.","systemMessage":"85094-TenantId 'vsphere.local' of subscription 'd449c824-2262-4e5f-a397-7d1b4d9ac822' does not match the provided in the URL path 'MTD'.","moreInfoUrl":null}]}

So either you're trying to modify a subscription from the wrong tenant URL or you're changing the tenant in the PUT and it doesn't match the what you have in the tenant URL.

View solution in original post

8 Replies
daphnissov
Immortal
Immortal
Jump to solution

Unfortunately, there isn't right now.

Reply
0 Kudos
bdamian
Expert
Expert
Jump to solution

I was able to get the tenant subscriptions from the API calling to:

/advanced-designer-service/api/tenants/demo/event-broker/subscriptions/

and then, I can get a single subscription with this:

/advanced-designer-service/api/tenants/demo/event-broker/subscriptions/847bbce8-2b4e-4c28-b245-a1c4d62cc149

All this using "administrator@vsphere.local" because is the only user with privileges to see this stuff.

But then, when I try to update with a PUT or create a new one with a POST, it throws me this error:

"message": "TenantId 'demo' of subscription '847bbce8-2b4e-4c28-b245-a1c4d62cc149' does not match the provided in the URL path 'vsphere.local'."

Any ideas?

D.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
Reply
0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

I tested this and didn't have any problems with it.  In my setup, I am logged in as a user federated from an Active Directory into a tenant named 'MTD'

I can do these no problems:

GET /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions to see list of subscriptions

GET /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions/d449c824-2262-4e5f-a397-7d1b4d9ac822 to see a specific subscription.  From that I receive:

{"id":"d449c824-2262-4e5f-a397-7d1b4d9ac822","eventTopicId":"com.vmware.csp.component.cafe.composition.component.completed","workflowId":"bcbcc2cf-abeb-4f19-a835-f66c3641018c","tenantId":"MTD","name":"Send Custom Activation E-mail","blocking":false,"reply":false,"status":"DRAFT","statusName":"Draft","criteria":null,"version":{"version":"0.0.0","major":0,"minor":0,"micro":0,"revision":null},"description":"","priority":10,"timeout":null}

Reuse the JSON gotten from there, but strip out the ID and change the name (by adding a '2' on the end):

{"eventTopicId":"com.vmware.csp.component.cafe.composition.component.completed","workflowId":"bcbcc2cf-abeb-4f19-a835-f66c3641018c","tenantId":"MTD","name":"Send Custom Activation E-mail 2","blocking":false,"reply":false,"status":"DRAFT","statusName":"Draft","criteria":null,"version":{"version":"0.0.0","major":0,"minor":0,"micro":0,"revision":null},"description":"","priority":10,"timeout":null}

POST that JSON back to /advanced-designer-service/api/tenants/MTD/event-broker/subscriptions/ and I get a HTTP 201 response and the subscription is created and shows up in the portal.

If I'm following what you want to do correctly, it seems that this works as intended.  Note that the user I am logged in with is a tenant administrator in the MTD tenant and has all of the roles assigned on the user account from within the Administration/Users & Groups area in the portal.  So maybe it's something to do with the account itself?

In my setup, administrator@vsphere.local does not have access to the tenant so I did not test with that account.

EDIT: just wanted to clarify this was tested on vRA 7.2.

EDIT2: I went back and re-read your post, and I think your issue might be that your POSTing and/or PUTting back to the subscription ID, but within the wrong tenant.

I can do a PUT to /api/tenants/MTD/event-broker/subscriptions/d449c824-2262-4e5f-a397-7d1b4d9ac822 using the original JSON (i.e. modifying it with no changes made) and I get an HTTP 204 response.  But if I modify the tenant in the JSON to "vsphere.local" instead of "MTD" I get an HTTP 400 with error similar to the one you saw:

{"errors":[{"code":85094,"message":"TenantId 'vsphere.local' of subscription 'd449c824-2262-4e5f-a397-7d1b4d9ac822' does not match the provided in the URL path 'MTD'.","systemMessage":"85094-TenantId 'vsphere.local' of subscription 'd449c824-2262-4e5f-a397-7d1b4d9ac822' does not match the provided in the URL path 'MTD'.","moreInfoUrl":null}]}

So either you're trying to modify a subscription from the wrong tenant URL or you're changing the tenant in the PUT and it doesn't match the what you have in the tenant URL.

jasnyder
Hot Shot
Hot Shot
Jump to solution

Hi, I saw you marked your own answer as correct but it doesn't have an answer to the problem, it states a problem and a question.  I'm thinking my explanation was correct because I was able to reproduce your error message reliably by putting the wrong tenant in the request.  If my answer was not correct, please explain what you did to fix this so others can see a resolution in the future.  If mine was correct, please mark it as the correct answer.

Reply
0 Kudos
hyperVisorGuy
Contributor
Contributor
Jump to solution

Does CodeStream with the Management Pack for IT DevOps  store this?

Reply
0 Kudos
samwalker1380
VMware Employee
VMware Employee
Jump to solution

A year too late... but it is possible using the cloud client... 

vra rest get --service event-broker-service --uri subscriptions --format JSON --export c:\file.json...  I have posted about doing something similar for property groups & definitions here:

https://www.6cd.co.uk/2019/01/using-vra-cloudclient-rest-calls-to.html

Reply
0 Kudos
vklinden
VMware Employee
VMware Employee
Jump to solution

There is also a built-in workflow in Orchestrator that you can get them with. It will save them as a resource that you can then save.

Reply
0 Kudos
xian_
Expert
Expert
Jump to solution

It should be

vra rest get --service advanced-designer-service --uri event-broker/subscriptions --format JSON --export c:\subscriptions.json

Also, if you don't use the default vsphere.local tenant, include the tenant uri as well:

vra rest get --service advanced-designer-service --uri tenants/mytenant/event-broker/subscriptions --format JSON --export c:\mytenant_subscriptions.json

thx jasnyder​​

Reply
0 Kudos