Tips for finding Knowledge Articles

  • - Enter just a few key words related to your question or problem
  • - Add Key words to refine your search as necessary
  • - Do not use punctuation
  • - Search is not case sensitive
  • - Avoid non-descriptive filler words like "how", "the", "what", etc.
  • - If you do not find what you are looking for the first time,reduce the number of key words you enter and try searching again.
  • - Minimum supported Internet Explorer version is IE9
Home  >
article

[HOWTO] Use Centrify REST API Python3 Package

Privileged Access Service ,  

25 September,20 at 05:49 PM

THIS IS A PURE EXAMPLE MODULE. CENTRIFY IS NOT RESPONSIBLE OR SUPPORT IT

#Link to Pypi project:
https://test.pypi.org/project/py3.centrify.rest.ex/
#Note that it is written and disclosed that this is a blog and NOT a Centrified solution. This goes through the setup process on how to use the example module.


#Important note that pandas is a terrible module to try to bundle with a distribution. If you know how to do it, please reach out.

Steps:
1. Install Python3 >=3.6.1
2.
pip3 install -i https://test.pypi.org/simple/ py3.centrify.rest.ex #if Linux
    a. pip install -i https://test.pypi.org/simple/ py3.centrify.rest.ex # if Windows
3. pip3 install pandas # if Linux
    a. pip install pandas # if Window
s
4. Go into Python 3
5. Run:

    from pas_config import make_config
    #COMPLETE EXAMPLE ON HOW TO MAKE THE FILE
    make_config.MakeConfig(TenantID="ABC1234", AppID="greyfox", Scope="big_boss", SvcAccount="master_miller@testing.com", PW='$ol1d$nak3')
    #This will create a config file in the current users working directory. This is what does all the authentication. in the centrify_pas module.

6. Then:
    from pas_py import *
    centrify_pas.<name_of_function>


All is done at that point. Has the capability to print and export all BASIC SQL queries (Need to test DateTime). Can do MOST REST API calls as well.

Prebuilt functions that can get all systems, accounts, connectors, etc; it is possible to configure it to have more information grabbed with the different key value pairs in basic query.

#LIST OF CURRENT FUNCTIONS/CLASSES#


#Ex of Utility Classes: 
#for Queries and outputs in tables. 
#Query_Request(SQL = """SELECT Server.DomainId, Server.DomainName, Server.ID, Server.Name FROM Server""", Debug=True) 
#Call Class to solidify URL endpoint [May deprecate] 
#Call1 = URL(Call= "/ServerManage/AddResource").new_url 
#All other Requests 
#Other_Request(Call="/ServerManage/AddResource",Debug= True, FQDN = "Gotem.net", ComputerClass= "Unix",\
#Sessiontype= "Ssh", Description="Test", Name="test.test.net")

#Ex of connector Function: 
#This gets 
#Connector_Info(Print=True, ExportPath="/home/a/Desktop/test1.csv")
Conn_Call_Ex
#Ex of Query Function: 
#This handles all basic Queries and can print them as a dataframe and/or Export it to a directory 
#Query(SQLQuery = """SELECT Server.DomainId, Server.DomainName, Server.ID, Server.Name FROM Server""", Print=True, ExportPath = "/home/a/Desktop/testtest.csv")

Ex_of_Query
#Ex of Secret classes/functions: 
#Get_Secret('test') 
#Add_Secret_Folder(Name="Test", Description="Test") 
#Delete_Secret(Secret='text')

#Ex of System classes/functions:
#Add_System(Name = "Test" ,FQDN="test.test.net", Description="test", ComputerClass="Unix", SessionType="Ssh") 
#Get_System(Name = "Test") 
#Get_System() -> Prints all systems and IDs and Domains with IDs 
#Delete_System("Test")
User-added image
#Ex of Account Functions: 
#Add_Account(User='Test', DomainName='test.net', Password='Password1') 
#Delete_Account(Name="Test") 
#Get_Vault_Account("testadmin") 
#Get_Vault_Account() # Prints all accounts and Ids of the account

#can build out all functions from the 2 utility classes; all of the functions are built off of the REST calls and JSON objects.

#FUTURE PLANS#
#1. Will remake the classes for the get functions so that they have properties to be called on.
    #a. recompile a new distro with executable functions/calls.
#2. Examples of a connection string to tenant to authenticate with the service account and then go forth with commands

If there is an issue, open bug with the issue on github. 

Attached is the source code at the time of writing this article.

Still have questions? Click here to log a technical support case, or collaborate with your peers in Centrify's Online Community.