Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Python FreeIPA API interface

Project description

pyfreeipa

Python module for accessing the FreeIPA/Red Hat Identity Manager API (a.k.a IPA)

This module does not do any exception handling, it wants your code to handle exceptions.

Usage

The following sample sets up a IPA API object with minimal configuration.

from pyfreeipa.Api import Api

ipaapi = Api(
    host="ipa.example.org",
    username="ipauser",
    password="somethingsecret"
)

response = ipaapi.ping()

if response.ok:
    result = response.json()['result']
    print('Good: %s' & result['summary'])
else:
    print('Bad: %s' % response.status_code)

Included is a configuration method that can read all the required configuration options from a yaml file.

Examples

The pyfreeipa module itself can be executed as a wrapper script around pyfreeipa.Api

There are also some test scripts that demonstrate it's capabilites in the test directory, they have their own documentation.

FreeIPA API Methods

The Api object supports both implemented and unimplemented methods

Unimplemented Methods

Unimplemented methods are supported via the Api.request() method:

from pyfreeipa.Api import Api

ipaapi = Api(
    host="ipa.example.org",
    username="ipauser",
    password="somethingsecret"
)

ipaapi.request(
    method='group_add_member',
    args=['groupname'],
    parameters={
        'users': [
            'anne',
            'bob',
            'claire'
        ]
    }
)

Implemented Methods

Other Methods

The Api object has a some methods that do not directly relate to requests to the IPA API

login()

The IPA API login process that isn't standard HTTPS authentication, this method initiates the login and should be sufficient to maintain login througout a session.

get()

A passthrough function that sends a GET request to the IPA API session. Returns a requests.response object.

post()

A passthrough function that sends a POST request to the IPA API session. Returns a requests.response object.

put()

A passthrough function that sends a PUT request to the IPA API session. Returns a requests.response object.

request()

This function checks and verifies it's argments and converts regular string, dictionary, and list objects and converts them into the required data types to submit as a request, executes the request and returns a requests.Response object.

Parameters

  • method A the IPA API method to be called
  • args A list of arguments for the method
  • params A dictionary of parameters for the method

preprequest()

This function checks and verifies it's argments and converts regular string, dictionary, and list objects and converts them into the required data types to submit as a request, executes the request and returns a requests.PreparedRequest object.

Parameters

  • method A the IPA API method to be called
  • args A list of arguments for the method
  • params A dictionary of parameters for the method

warnings

Emits a list of warnings that have occured.

clearwarnings()

Clears the warnings list.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyFreeIPA, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size PyFreeIPA-0.1.0-py3-none-any.whl (14.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size PyFreeIPA-0.1.0.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page