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
The API methods implemented is incomplete as we're only adding them as we need them, each of these methdos includes some sanity checking, doing case insensitivity checks where necessary, and cleaning up the output so it's predictably formatted.
user_showuser_finduserusersuserlistuser_getattruser_moduser_addgroup_findgroupgroupsgrouplistgroup_add_memberotptoken_findotptoken_showotptokenotptokensotptoken_remove_managedbyotptoken_add_managedbyotptoken_add
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
methodA the IPA API method to be calledargsA list of arguments for the methodparamsA 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.
The use of preprequest() and send() methods allow a POST request to be prepared, then it can be examined or checked, and then if it's valid the send() method can execute it. Another use case is a 'dry run' scenario where the request can be prepared, but not executed.
Parameters
methodA the IPA API method to be calledargsA list of arguments for the methodparamsA dictionary of parameters for the method
send()
This function sends a prepared request from the preprequest() function and sends it to be executed and returns a requests.Response object.
Parameters
preprequestArequests.PreparedRequestobject, as per what's produced bypreprequest()
warnings
Emits a list of warnings that have occured.
clearwarnings()
Clears the warnings list.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfreeipa-0.2.5.tar.gz.
File metadata
- Download URL: pyfreeipa-0.2.5.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4cece8a1fa80117627909a9b514d5f1b34383bb4ebce70a9d6943ff58fc4a4
|
|
| MD5 |
4c518665357e40564bee4352a8a05d78
|
|
| BLAKE2b-256 |
712e1afd1425bae70213a8e42cf04626035cc96e1d5da3075fca8c06691632d2
|
Provenance
The following attestation bundles were made for pyfreeipa-0.2.5.tar.gz:
Publisher:
publish-to-pypi.yml on niwa/pyfreeipa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfreeipa-0.2.5.tar.gz -
Subject digest:
1b4cece8a1fa80117627909a9b514d5f1b34383bb4ebce70a9d6943ff58fc4a4 - Sigstore transparency entry: 236969351
- Sigstore integration time:
-
Permalink:
niwa/pyfreeipa@50397530cd82c38b3fb110c377a344417e09fd25 -
Branch / Tag:
refs/tags/0.2.5 - Owner: https://github.com/niwa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@50397530cd82c38b3fb110c377a344417e09fd25 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyfreeipa-0.2.5-py3-none-any.whl.
File metadata
- Download URL: pyfreeipa-0.2.5-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be020794015a18804c5ca47281548fb963954e38f238ece80477410538c0e667
|
|
| MD5 |
0a894f2542d1b0074f0dd6fa36ed5b66
|
|
| BLAKE2b-256 |
1641310d778a7f7bdb58f361e17e371b32fa54a2cfebb3c31f622f5b1198b9a3
|
Provenance
The following attestation bundles were made for pyfreeipa-0.2.5-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on niwa/pyfreeipa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfreeipa-0.2.5-py3-none-any.whl -
Subject digest:
be020794015a18804c5ca47281548fb963954e38f238ece80477410538c0e667 - Sigstore transparency entry: 236969359
- Sigstore integration time:
-
Permalink:
niwa/pyfreeipa@50397530cd82c38b3fb110c377a344417e09fd25 -
Branch / Tag:
refs/tags/0.2.5 - Owner: https://github.com/niwa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@50397530cd82c38b3fb110c377a344417e09fd25 -
Trigger Event:
push
-
Statement type: