Re: [Freeipa-users] JSON-RPC documentation?

2013-01-15 Thread Petr Viktorin

Hello Brian,

On 01/15/2013 03:55 AM, Brian Smith wrote:

That helps a lot.  Thanks!  I would use ipalib, but I'm developing a
Rails application, so the JSON interface is the quickest (and since XML
may be deprecated)


While XML may be deprecated, it'll stick around for a long time. But 
JSON is a good choice.



best way forward (unless you know a way to use it in
Ruby :).  I'm guessing in JSON, the structure would look something like
this:

{
   method: user_add,
   params: [
 [],
 {
   uid:testuser,
   givenname:Test,
   sn:User,
   userpassword:mySecretPasswordBlahBlah
   ...
 }
   ]
}

Maybe I'll try to compile some documentation.  I know that this page
helped a lot, to cook up a quick ruby client with Curb:
http://adam.younglogic.com/2010/07/talking-to-freeipa-json-web-api-via-curl/



I've just CC-d you on a patch to the devel list that switches the IPA 
client to JSON-RPC. To use it:


- Check out the git master and apply the patch
- Copy /etc/ipa/default.conf to ~/.ipa/default.conf
- Now a command like `./ipa -vv user-find` will print out the JSON it 
sends  receives.
It dumps the whole request/response so the output is not ideal for your 
use, but I'm sure you can handle it.

It works from the source tree, no build/installation required.


You probably found out that the CLI options and API options/LDAP 
attributes sometimes have different names. The `ipa show-mappings` 
command can give you a mapping table.



One more thing: please add the API version to your requests to prevent 
surprises down the road. The official client doesn't currently always do 
that; this is a bug. You can get the current version with `ipa ping`:


$ ipa ping
--
IPA server version 3.1.0. API version 2.47
--

{
   method: user_add,
   params: [
 [],
 {
   uid:testuser,
   givenname:Test,
   sn:User,
   userpassword:mySecretPasswordBlahBlah
   ...
   version: 2.47,
 }
   ]
}

--
PetrĀ³

___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users


Re: [Freeipa-users] JSON-RPC documentation?

2013-01-15 Thread Petr Vobornik

Spying Web UI might be another way how to learn the API.

Web UI uses JSON interface for everything it does. You can open 
developer tools in Chrome (hit F12) and watch communication (network 
tab). Do something and then look for requests named 'json' a inspect the 
request payload.


To inspect the API alone you can go through metadata (in console tab) 
which are stored in IPA.metadata object but I guess inspecting python 
code might be easier.


HTH

On 01/15/2013 03:55 AM, Brian Smith wrote:

That helps a lot.  Thanks!  I would use ipalib, but I'm developing a Rails
application, so the JSON interface is the quickest (and since XML may be
deprecated) best way forward (unless you know a way to use it in Ruby :).
  I'm guessing in JSON, the structure would look something like this:

{
   method: user_add,
   params: [
 [],
 {
   uid:testuser,
   givenname:Test,
   sn:User,
   userpassword:mySecretPasswordBlahBlah
   ...
 }
   ]
}

Maybe I'll try to compile some documentation.  I know that this page helped
a lot, to cook up a quick ruby client with Curb:
http://adam.younglogic.com/2010/07/talking-to-freeipa-json-web-api-via-curl/


On Mon, Jan 14, 2013 at 9:35 PM, Rob Crittenden rcrit...@redhat.com wrote:


Dmitri Pal wrote:


On 01/14/2013 08:16 PM, Brian Smith wrote:


Before I pester the dev list, I was wondering if anyone here could
point me to documentation on the JSON-RPC interface to FreeIPA.  I'm
not doing anything fancy, just adding users and updating passwords, so
my requirements are pretty tame.  I've gone through the Python code
and have somewhat pieced it together myself, but would be more
comfortable if there were official docs.

  I do not remember us having documentation about XML-RPC but I will

check.
We are actually debating deprecating XML-RPC over time in favor of JSON.



There is no official documentation on either XML-RPC or JSON. The format
is rather straightforward once you get the hang of things. Each command is
effectively an RPC function (e.g ipa user-add - user_add). The arguments
consist of positional arguments followed by named arguments (there is
usually only one positional arg).

For XML-RPC it is generally fairly easy to work out what it's doing by
adding -vv option to the command-line to see the raw request and response.
I personally haven't done a lot of raw JSON work.

The final option is to skip all that and use the ipalib to do the work for
you.

For example, to add a user you'd do something like:

from ipalib import api
from ipalib import errors

api.bootstrap(context='cli')
api.finalize()
api.Backend.xmlclient.connect(**)

try:
 api.Command['user_add'](u'**newuser',
 loginshell=u'/bin/something',
 givenname=u'New', sn=u'User')
except errors.DuplicateEntry:
 print user already exists
else:
 print user added




___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users




--
Petr Vobornik

___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users


Re: [Freeipa-users] JSON-RPC documentation?

2013-01-15 Thread Brian Smith
These posts have all been really helpful (especially -vv... its mostly
trivial to translate to JSON from the XML).  Thanks a lot for the
suggestions!

I do have one question that might be a new thread, but for me its related.
 I've added a service account user to the passSyncManagersDNs multi-valued
list to avoid the initial account expiration, but it seems to put a 3 month
expiration on the account despite the fact that my global password policy
is 180 days.  Anyone know what gives?

Thanks again!
-Brian


On Tue, Jan 15, 2013 at 6:55 AM, Petr Vobornik pvobo...@redhat.com wrote:

 Spying Web UI might be another way how to learn the API.

 Web UI uses JSON interface for everything it does. You can open developer
 tools in Chrome (hit F12) and watch communication (network tab). Do
 something and then look for requests named 'json' a inspect the request
 payload.

 To inspect the API alone you can go through metadata (in console tab)
 which are stored in IPA.metadata object but I guess inspecting python code
 might be easier.

 HTH


 On 01/15/2013 03:55 AM, Brian Smith wrote:

 That helps a lot.  Thanks!  I would use ipalib, but I'm developing a Rails
 application, so the JSON interface is the quickest (and since XML may be
 deprecated) best way forward (unless you know a way to use it in Ruby :).
   I'm guessing in JSON, the structure would look something like this:

 {
method: user_add,
params: [
  [],
  {
uid:testuser,
givenname:Test,
sn:User,
userpassword:**mySecretPasswordBlahBlah
...
  }
]
 }

 Maybe I'll try to compile some documentation.  I know that this page
 helped
 a lot, to cook up a quick ruby client with Curb:
 http://adam.younglogic.com/**2010/07/talking-to-freeipa-**
 json-web-api-via-curl/http://adam.younglogic.com/2010/07/talking-to-freeipa-json-web-api-via-curl/


 On Mon, Jan 14, 2013 at 9:35 PM, Rob Crittenden rcrit...@redhat.com
 wrote:

  Dmitri Pal wrote:

  On 01/14/2013 08:16 PM, Brian Smith wrote:

  Before I pester the dev list, I was wondering if anyone here could
 point me to documentation on the JSON-RPC interface to FreeIPA.  I'm
 not doing anything fancy, just adding users and updating passwords, so
 my requirements are pretty tame.  I've gone through the Python code
 and have somewhat pieced it together myself, but would be more
 comfortable if there were official docs.

   I do not remember us having documentation about XML-RPC but I will

 check.
 We are actually debating deprecating XML-RPC over time in favor of JSON.


 There is no official documentation on either XML-RPC or JSON. The format
 is rather straightforward once you get the hang of things. Each command
 is
 effectively an RPC function (e.g ipa user-add - user_add). The arguments
 consist of positional arguments followed by named arguments (there is
 usually only one positional arg).

 For XML-RPC it is generally fairly easy to work out what it's doing by
 adding -vv option to the command-line to see the raw request and
 response.
 I personally haven't done a lot of raw JSON work.

 The final option is to skip all that and use the ipalib to do the work
 for
 you.

 For example, to add a user you'd do something like:

 from ipalib import api
 from ipalib import errors

 api.bootstrap(context='cli')
 api.finalize()
 api.Backend.xmlclient.connect()

 try:
  api.Command['user_add'](u'newuser',

  loginshell=u'/bin/something',
  givenname=u'New', sn=u'User')
 except errors.DuplicateEntry:
  print user already exists
 else:
  print user added



 __**_
 Freeipa-users mailing list
 Freeipa-users@redhat.com
 https://www.redhat.com/**mailman/listinfo/freeipa-usershttps://www.redhat.com/mailman/listinfo/freeipa-users



 --
 Petr Vobornik




-- 
Brian Smith
Assistant Director
Research Computing, University of South Florida
4202 E. Fowler Ave. SVC4010
Office Phone: +1 813 974-1467
Organization URL: http://rc.usf.edu
___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users

Re: [Freeipa-users] JSON-RPC documentation?

2013-01-14 Thread Dmitri Pal
On 01/14/2013 08:16 PM, Brian Smith wrote:
 Before I pester the dev list, I was wondering if anyone here could
 point me to documentation on the JSON-RPC interface to FreeIPA.  I'm
 not doing anything fancy, just adding users and updating passwords, so
 my requirements are pretty tame.  I've gone through the Python code
 and have somewhat pieced it together myself, but would be more
 comfortable if there were official docs.

I do not remember us having documentation about XML-RPC but I will check.
We are actually debating deprecating XML-RPC over time in favor of JSON.

 Thanks,

 -- 
 Brian Smith
 Assistant Director
 Research Computing, University of South Florida
 4202 E. Fowler Ave. SVC4010
 Office Phone: +1 813 974-1467
 Organization URL: http://rc.usf.edu


 ___
 Freeipa-users mailing list
 Freeipa-users@redhat.com
 https://www.redhat.com/mailman/listinfo/freeipa-users


-- 
Thank you,
Dmitri Pal

Sr. Engineering Manager for IdM portfolio
Red Hat Inc.


---
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/



___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users

Re: [Freeipa-users] JSON-RPC documentation?

2013-01-14 Thread Rob Crittenden

Dmitri Pal wrote:

On 01/14/2013 08:16 PM, Brian Smith wrote:

Before I pester the dev list, I was wondering if anyone here could
point me to documentation on the JSON-RPC interface to FreeIPA.  I'm
not doing anything fancy, just adding users and updating passwords, so
my requirements are pretty tame.  I've gone through the Python code
and have somewhat pieced it together myself, but would be more
comfortable if there were official docs.


I do not remember us having documentation about XML-RPC but I will check.
We are actually debating deprecating XML-RPC over time in favor of JSON.


There is no official documentation on either XML-RPC or JSON. The format 
is rather straightforward once you get the hang of things. Each command 
is effectively an RPC function (e.g ipa user-add - user_add). The 
arguments consist of positional arguments followed by named arguments 
(there is usually only one positional arg).


For XML-RPC it is generally fairly easy to work out what it's doing by 
adding -vv option to the command-line to see the raw request and 
response. I personally haven't done a lot of raw JSON work.


The final option is to skip all that and use the ipalib to do the work 
for you.


For example, to add a user you'd do something like:

from ipalib import api
from ipalib import errors

api.bootstrap(context='cli')
api.finalize()
api.Backend.xmlclient.connect()

try:
api.Command['user_add'](u'newuser',
loginshell=u'/bin/something',
givenname=u'New', sn=u'User')
except errors.DuplicateEntry:
print user already exists
else:
print user added

___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users


Re: [Freeipa-users] JSON-RPC documentation?

2013-01-14 Thread Brian Smith
That helps a lot.  Thanks!  I would use ipalib, but I'm developing a Rails
application, so the JSON interface is the quickest (and since XML may be
deprecated) best way forward (unless you know a way to use it in Ruby :).
 I'm guessing in JSON, the structure would look something like this:

{
  method: user_add,
  params: [
[],
{
  uid:testuser,
  givenname:Test,
  sn:User,
  userpassword:mySecretPasswordBlahBlah
  ...
}
  ]
}

Maybe I'll try to compile some documentation.  I know that this page helped
a lot, to cook up a quick ruby client with Curb:
http://adam.younglogic.com/2010/07/talking-to-freeipa-json-web-api-via-curl/


On Mon, Jan 14, 2013 at 9:35 PM, Rob Crittenden rcrit...@redhat.com wrote:

 Dmitri Pal wrote:

 On 01/14/2013 08:16 PM, Brian Smith wrote:

 Before I pester the dev list, I was wondering if anyone here could
 point me to documentation on the JSON-RPC interface to FreeIPA.  I'm
 not doing anything fancy, just adding users and updating passwords, so
 my requirements are pretty tame.  I've gone through the Python code
 and have somewhat pieced it together myself, but would be more
 comfortable if there were official docs.

  I do not remember us having documentation about XML-RPC but I will
 check.
 We are actually debating deprecating XML-RPC over time in favor of JSON.


 There is no official documentation on either XML-RPC or JSON. The format
 is rather straightforward once you get the hang of things. Each command is
 effectively an RPC function (e.g ipa user-add - user_add). The arguments
 consist of positional arguments followed by named arguments (there is
 usually only one positional arg).

 For XML-RPC it is generally fairly easy to work out what it's doing by
 adding -vv option to the command-line to see the raw request and response.
 I personally haven't done a lot of raw JSON work.

 The final option is to skip all that and use the ipalib to do the work for
 you.

 For example, to add a user you'd do something like:

 from ipalib import api
 from ipalib import errors

 api.bootstrap(context='cli')
 api.finalize()
 api.Backend.xmlclient.connect(**)

 try:
 api.Command['user_add'](u'**newuser',
 loginshell=u'/bin/something',
 givenname=u'New', sn=u'User')
 except errors.DuplicateEntry:
 print user already exists
 else:
 print user added


 __**_
 Freeipa-users mailing list
 Freeipa-users@redhat.com
 https://www.redhat.com/**mailman/listinfo/freeipa-usershttps://www.redhat.com/mailman/listinfo/freeipa-users




-- 
Brian Smith
Assistant Director
Research Computing, University of South Florida
4202 E. Fowler Ave. SVC4010
Office Phone: +1 813 974-1467
Organization URL: http://rc.usf.edu
___
Freeipa-users mailing list
Freeipa-users@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-users