Skip to main content

Posts

Showing posts with the label Python

List of users and status in IICS using API

This python script lists out users , email and status from Informatica. You need to replace your username, password and informatica url. import requests import json import sys import datetime import smtplib, ssl from email.mime.base import MIMEBase from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart filename="userslist.txt" username = "" password = "" current_timestamp = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') with open(filename, 'w') as f:   f.write(current_timestamp+'\n') username = username password = password url = "https://dm-us.informaticacloud.com/saas/public/core/v3/login" payload = json.dumps({   "username": username,   "password": password }) headers = {   'Content-Type': 'application/json',   'Accept': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) login=jso...

List of Groups and Users in IICS

 I have written a  python script to pull list of groups and associated users in ICCS using API.  In script you need to replace url and Id and password that has admin access in your environment.  Here is the script import requests import json sid= '' url = "https:Infaurl/api/v2/user/login" payload = json.dumps({ "username" : "Adminuser" , "password" : "Adminpassword" }) headers = { 'Content-Type' : 'application/json' , 'Accept' : 'application/json' } response = requests.request( "POST" , url, headers =headers, data =payload) print (response.text) login=json.loads(response.text) for i in login: if i== "icSessionId" : sid=login[i] #print(sid) groupurl = "https://infaurl/public/core/v3/userGroups?limit=50" payload = {} grpheaders = { 'INFA-SESSION-ID' : sid } groupresponse = requests.request( "GET" , groupurl, headers =grphe...

Script to get Disabled users in IICS

 Script to get Disabled users in IICS   This script user Informatica Cloud APIs to get user details and pulls disabled and locked users even if SAML is integrated. You need to replace username, password, send email, receiver email and SMPT server so that it generated disabled users list for that org in the same path from where you are running the script.  import requests import json import sys import datetime import smtplib, ssl from email.mime.base import MIMEBase from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart filename= "userslist.txt" username = "username" password = "Password" current_timestamp = datetime.datetime.utcnow().strftime( '%Y-%m-%d %H:%M:%S' ) with open (filename, 'w' ) as f: f.write(current_timestamp+ ' \n ' ) username = username password = password url = "https://dm-us.informaticacloud.com/saas/public/core/v3/login" payload = json.dumps({ "username" : user...

Automate Password Updates using Python for Workbooks, datasources and flows

               Most of the Companies adhere to password policy of 60-90 days . Tableau workbooks, Datasources and Flows needs to have the DB password updated adhering to the policy.               I want to make an executable that makes easy to change the passwords. Here is the new Executable that helps to change the passwords in tableau objects. import tableauserverclient as TSC import argparse ,os, configparser, re from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter import logging import datetime CONFIGURATION_FILE="passwordconfig.txt" #configuration file name and path.  #Copy the config file from the below  #logmodule def create_logger(log_id):     logger = logging.getLogger(log_id)     logger.setLevel(logging.DEBUG)     fh = logging.FileHandler(filename="passwordchangelog.txt") #log filename and its path     fh.setLevel(logging.DEB...

Create Users using Tableau API and Python

Create Users using Tableau API and Python User file will be in the format of userid, roleof the user. user1,Explorer user2,Creator User3,Viewer import tableauserverclient as TSC import csv userfile= open('C:/Users/myartha/Documents/Python Files/users_06112020.csv') usr = csv.reader(userfile) sourceusers=[] createdusers=[] pat = 'PersonalAccessToken'  #your personal access token created on the UI server = TSC.Server('<servername>') # provide your server URL siteid='siteid'   #yoursiteid from the server. This is not the nameof the site but id of the site tokenName = 'UserGroupScript'  #provide your Token name used when creating personal access Token server.version='3.6' ta = TSC.PersonalAccessTokenAuth(token_name=tokenName, personal_access_token=pat, site_id=siteid) with server.auth.sign_in_with_personal_access_token(ta):     userlist, pagination_item=server.users.get()     for user in userlist:         sourceusers.append(u...

Create Projects using Tableau API and Python

Creating Tableau Projects and child projects with Tableau API and Python Prerequisites: Python on the machine tableauserverclient module API enabled on Tableau server. Permissions to update for the user Projects.csv file . list all groups in a csv file. attached format . Changes to be made in the script for below lines in the script groups = open('<Filepath>/groups.csv') pat='getyourpersonaltoken' server = TSC.Server('http://myserver.tableau.com',use_server_version=True) tokenName = 'mytokenname' Script: import tableauserverclient as TSC import csv Projects = open('filepath/projects.csv') prjt = csv.reader(Projects) projectstobe = list(prjt) sourceprojects =[] createdprjts = [] parentproj_id='' pr_perm = TSC.ProjectItem.ContentPermissions.ManagedByOwner pat = 'personalaccesstoken' server = TSC.Server('http://myserver.tableau.com', use_server_version=True) tokenName = 'mytokenname' ta = TSC.PersonalAccessToke...

Creating Groups using Tableau API and Python Script

 Creating Tableau Groups using Python and API Prerequisites: Python on the machine tableauserverclient module API enabled on Tableau server. Permissions to update for the user Groups.csv file . list all groups in a csv file Changes to be made in the script for below lines in the script groups = open('<Filepath>/groups.csv') pat='getyourpersonaltoken' server = TSC.Server('http://myserver.tableau.com',use_server_version=True) tokenName = 'mytokenname' Script: import tableauserverclient as TSC import csv groups = open('<Filepath>/groups.csv') grp = csv.reader(groups) sourcegroups=[] createdgrps=[] pat='getyourpersonaltoken' server = TSC.Server('http://myserver.tableau.com',use_server_version=True) tokenName = 'mytokenname' ta = TSC.PersonalAccessTokenAuth(token_name=tokenName, personal_access_token=pat) with server.auth.sign_in_with_personal_access_token(ta):    groupslist, pagination_item  = server.groups.get() ...