2008-07-18 12:51:34 -05:00
|
|
|
# Authors:
|
|
|
|
# Jason Gerard DeRose <jderose@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation; version 2 only
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2008-07-18 15:31:12 -05:00
|
|
|
|
|
|
|
"""
|
2008-08-14 04:01:02 -05:00
|
|
|
The IPA Library.
|
|
|
|
|
2008-08-14 14:36:54 -05:00
|
|
|
To learn about the ``ipalib`` library, you should read the code in this order:
|
2008-08-14 04:01:02 -05:00
|
|
|
|
2008-08-14 14:36:54 -05:00
|
|
|
1. Learn about the plugin framework in `ipalib.plugable`
|
2008-08-14 04:01:02 -05:00
|
|
|
|
2008-08-14 22:24:37 -05:00
|
|
|
2. Learn about the public API in `ipalib.public`
|
2008-08-14 14:36:54 -05:00
|
|
|
|
|
|
|
3. Look at some example plugins in `ipalib.plugins.example`
|
2008-08-14 04:01:02 -05:00
|
|
|
|
2008-08-25 19:04:15 -05:00
|
|
|
Here is a short console example on using the plugable API:
|
|
|
|
|
|
|
|
>>> from ipalib import api
|
|
|
|
>>> list(api.register) # Plugins must subclass from one of these base classes:
|
|
|
|
['Command', 'Method', 'Object', 'Property']
|
|
|
|
>>> 'user_add' in api.register.Command # Has 'user_add' been registered?
|
|
|
|
False
|
|
|
|
>>> import ipalib.load_plugins # This causes all plugins to be loaded
|
|
|
|
>>> 'user_add' in api.register.Command # Yes, 'user_add' has been registered:
|
|
|
|
True
|
|
|
|
>>> list(api) # API is empty till finalize() is called:
|
|
|
|
[]
|
|
|
|
>>> api.finalize() # Instantiates plugins, builds API namespaces:
|
|
|
|
>>> list(api) # Lists the namespaces in the API:
|
|
|
|
['Command', 'Method', 'Object', 'Property']
|
|
|
|
>>> 'user_add' in api.Command # Yes, the 'user_add' command exists:
|
|
|
|
True
|
|
|
|
>>> api['Command'] is api.Command # Access as dict item or as attribute:
|
|
|
|
True
|
|
|
|
>>> list(api.Command) # List available commands:
|
|
|
|
['discover', 'group_add', 'group_del', 'group_find', 'group_mod', 'krbtest', 'service_add', 'service_del', 'service_find', 'service_mod', 'user_add', 'user_del', 'user_find', 'user_mod']
|
|
|
|
>>> list(api.Command.user_add) # List public methods for user_add:
|
|
|
|
['__call__', 'default', 'execute', 'get_doc', 'normalize', 'options', 'validate']
|
2008-07-18 15:31:12 -05:00
|
|
|
"""
|
2008-08-25 18:35:29 -05:00
|
|
|
|
|
|
|
import plugable
|
|
|
|
import public
|
|
|
|
|
|
|
|
api = plugable.API(
|
|
|
|
public.Command,
|
|
|
|
public.Object,
|
|
|
|
public.Method,
|
|
|
|
public.Property,
|
|
|
|
)
|