-
Notifications
You must be signed in to change notification settings - Fork 446
Description
#Subscription script- runs but does not create a subscription for a user on workbook, of a schedule
import tableauserverclient as tsc
tauth = tsc.TableauAuth('ID', 'PWD', site_id='Sitename')
server = tsc.Server('serverURL', use_server_version=True)
server.auth.sign_in(tauth)
#to get workbookID
req_option = tsc.RequestOptions()
req_option.filter.add(tsc.Filter(tsc.RequestOptions.Field.Name,
tsc.RequestOptions.Operator.Equals,
'Product Version Dashboard test 2'))
workobj = server.workbooks.get(req_option)
print('workobj', workobj[0][0].name)
workbookid = workobj[0][0].id
print(workbookid)
target = (workbookid, 'workbook')
print('target:', target)
#To get schedule ID of schedule "11AM EST Daily"
subobj= server.schedules.get()
for sbj in subobj[0]:
if sbj.name =="11AM EST Daily":
sbjid = (sbj.id)
print(sbj.name ,sbjid)
print('sbj', sbj[0][0])
req_opt = tsc.RequestOptions()
req_opt.filter.add(tsc.Filter(tsc.RequestOptions.Field.Name, tsc.RequestOptions.Operator.Equals, 'cordellr'))
u = server.users.get(req_opt)
print('u', u)
uid = u[0][0].id
print('uid',uid)
subscipid = server.subscriptions.get()
print('subscipid', subscipid[0][0].target)
create a new SubscriptionItem object.
newSub = tsc.SubscriptionItem('My Subscription', sbjid, uid, target)
print('newSub', newSub)
#output generated: but the subscription did not get created for user who is Site admin having all access #to the site connection
#newSub <Subscription subject(My Subscription) schedule_id(eb92f0ab-0cfc-422d-#b87e-1e23522f1106) #user_id(62d9dee9-10c8-4fcf-ab04-99981f770204) target(('c95c0459-#34ea-47e1-8871-#badcab1e875c', 'workbook'))