Getting all Clients via API

Discussion in 'Developers' Forum' started by teves, Jun 20, 2012.

  1. teves

    teves Member

    Hello,

    can someone please tell me if there is a way to retrieve all clients at once via the API?

    Thank you!

    regards, Tom
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    This should work:


    $clients = $client->client_get($session_id, array('parent_client_id' => '0'));
     
  3. teves

    teves Member

    hi Till,

    this works perfectly, thank you very much!
    I looked it up in the API documentation contained in the ISPConfig release package, but could not find a hint. Did I miss it or is it not in there? Is there another place where I can find out the details of the API without bugging you all the time? ;-)

    Regards, Tom
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Hi,

    all ..._get() functions in the API support a array as ID parameter and in the array you can use any field of the corresponding database table. The values can contain % as wildcard.

    so this query:

    $clients = $client->client_get($session_id, array('contact_name' => '%John%'));

    woud return all clients were "John" is in the contact name field.
     
  5. teves

    teves Member

    Hi,

    thanks! This is a very helpful piece of information!

    Most recently I have programmed for Plesk, and I have to point out that their RPC API ist a large pile of crap (and their support is even worse). I have not seen a lot of the ISPConfig API yet, but I like it much better already.... ;-)

    And, btw, I have seen a lot of the ISPConfig community support, and I cannot stress enough how great it is!


    Regards, Tom
     
  6. teves

    teves Member

    I am sorry but I have another question...

    I would like to create a list of domains of a certain client (via API), but the domain array I get via SOAP does not seem to contain information on the owner client.
    When I fetch all domains and try to find out the clients via the client_get_id function, I only get the admin ID (which is the user who created the domains).

    The api function domains_get_all_by_user gives a list of the domains created by a certain user, I assume? But this does not help me here...

    But in Ispconfig, Tab "Sites", there is a list of the domains, with the owner clients in front. So there must be a way...

    Can someone give me a hint please?

    Regards, Tom
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The records conatin the user and group information. Every client has its own group, so you can select them by filtering on the group ID which is associated with the client.
     
  8. teves

    teves Member

    When I try to fetch the subdomains of a domain with the following SOAP request:
    sites_web_subdomain_get($session_id, array("parent_domain_id" => $id) )
    I do not only get the subdomains, but also the aliasdomains with the same parent_domain_id. Is this bug or feature?

    I tested it with the request
    sites_web_aliasdomain_get($session_id, array("parent_domain_id" => $id))
    too, the behaviour is exactly the same....

    So the output of two different SOAP commands is the same, this can't be intentional, can it?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Both commands work on the same table and with array("parent_domain_id" => $id) you override all other selections. If you want to use the array paremeter and get subdomains only, then the query is:

    sites_web_subdomain_get($session_id, array("parent_domain_id" => $id,"type" => 'subdomain') )
     
  10. teves

    teves Member

    It should be mentioned that it is necessary to use the undocumented (!) SOAP call
    client_get_groupid($session_id, $client_id)
    to obtain the group_id of a client. Strangely, the group_id is not included in the answers to the client_get() and client_get_by_username() functions.
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats the function to convert the client ID to groupid, if you want to convert from one ID to another then you have to use that function of course.

    The grouid is part of the response of any record, it does not amtter if you query a website or a client. print out the response with print_r(), you will see that the sys_groupid is returned. The groupid of a record is the owner group of that record and the client records are owned by the administrator or reseller that created them. So the grouipd of a client record is either the groupid of the admin or the groupid of the reseller.
     
  12. teves

    teves Member

    Hi Till,

    please forgive me if I got something wrong, but I still believe that my post is correct in the given context:

    my aim is to create a list of domains belonging to a certain client. So I would fetch the client first by client_get() or client_get_by_username().
    But then I only get the sys_groupid of the client, which is, as you pointed out, the id of the admin or the reseller.
    Now I would need to send a request like sites_web_domain_get($session_id, array('sys_groupid' => $id))
    and here I need the group_id of the user, which I do not have at this point.
    So I'd use the client_get_groupid($session_id, $client_id) function.

    Did I get something wrong? Is there a better way?

    Regards, Tom
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    If you write a external application for ispconfig, then you have the client_id as universal reference stored in your app. So normally you wont query the client table at all except if you want to change client details. This ID can be used to query a client and this ID can also be used to query for the groupid of that client if you need it for other queries.
     

Share This Page