TheJumpCloud / jcapi-python

21 stars 20 forks source link

Group #25

Open mr-brody opened 5 years ago

mr-brody commented 5 years ago

Hi, I am trying to use the groupsApi for jumpcloud api version2. I've noticed for a few APIs there is a results attribute tied to the returned values. This is good because I can essentially know how many entries exist and can paginate through the results until I reach the end.

For the groups API, I could not find the same. It looks like the datatype returned is a list and only 100 results can be returned in a given API call. This force you to guess how many groups there are. I can compare the current groups to what I have in the console but would like to see if there was another way to perform this action or to file this as a feature improvement for the amount of total entries to be returned in the api call. Below is my code snippet. Thanks!

from __future__ import print_function
import time
import jcapiv2
from jcapiv2.rest import ApiException
from pprint import pprint
import os

# Configure API key authorization: x-api-key
configuration = jcapiv2.Configuration()
configuration.api_key['x-api-key'] = os.environ['jc_api_key']
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'

# create an instance of the API class
api_instance = jcapiv2.GroupsApi(jcapiv2.ApiClient(configuration))
content_type = 'application/json' # str |  (default to application/json)
accept = 'application/json' # str |  (default to application/json)
fields = ['[]'] # list[str] | The comma separated fields included in the returned records. If omitted, the default list of fields will be returned.  (optional) (default to [])
#filter = ['[]'] # list[str] | Supported operators are: eq, ne, gt, ge, lt, le, between, search, in (optional) (default to [])
#limit = 100 # int | The number of records to return at once. Limited to 100. (optional) (default to 10)
#skip = 0 # int | The offset into the records to return. (optional) (default to 0)
sort = ['[]'] # list[str] | The comma separated fields used to sort the collection. Default sort is ascending, prefix with `-` to sort descending.  (optional) (default to [])
#x_org_id = '' # str |  (optional) (default to )

api_response = api_instance.groups_list(content_type, accept, limit=100)
print(type(api_response))
<class 'list'>