Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (50 sloc) 1.98 KB

General tips

Verify connectivity with Rtpy self call

Call an instantiated Rtby object to verify connectivity (binding to the system health ping method)

import rtpy

# instantiate a Rtpy object
settings = {}
settings["af_url"] = "http://..."
settings["api_key"] = "123QWA..."
# settings["username"] = "my_username"
# settings["password"] = "my_password"

af = rtpy.Rtpy(settings)
r = af()
# or r = af.system_and_configuration.system_health_ping()
# print(r)
# OK

Environment variables as settings

Use environement variables for the api_key and af_url in the settings dictionary

settings = {}
settings["af_url"] = os.environ["ARTIFACTORY_URL"] # URL of the AF instance
settings["api_key"] = os.environ["ARTIFACTORY_API_KEY"] # User/Admin API key in the given AF instance

af = rtpy.Rtpy(settings)

Overriding settings

All the settings can be overridden for a single function call (original settings are restored when the call is over) This is useful for debugging (verbose level) or not raising errors (raw_response). It can also be used to provide different credentials

r = af.category.method_xyz(settings={"raw_response" : True, "verbose_level" : 1})

r = af.category.method_xyz(settings={"verbose_level" : 1})

r = af.category.method_xyz(settings={"api_key" : "123ABC..."})

session = requests.Session()
session.verify = "path/to/ca_bundle.crt"
r = af.category.method_xyz(settings={"session" : session})


Use the pprint package to print the json responses in a more readable way

from pprint import pprint
r = af.category.method_xyz()

Json file to Python dictionary

Convert a json file to a python dictionnary using the json_to_dict method

my_dict = rtpy.json_to_dict(json_file_path)
You can’t perform that action at this time.