<jupyter_start><jupyter_text>What _projects_ am I a member of? OverviewThere are a number of API calls related to projects. Here we focus on listing projects. As with any **list**-type call, we will get minimal information about each project. There are two versions of this call: 1. (default) **paginated** call that will return 50 projects 2. **all-records** call that will page through and return all projects  Prerequisites 1. You need to be a member (or owner) of _at least one_ project. 2. You need your _authentication token_ and the API needs to know about it. See **Setup_API_environment.ipynb** for details.  ImportsWe import the _Api_ class from the official sevenbridges-python bindings below.<jupyter_code>import sevenbridges as sbg<jupyter_output><empty_output><jupyter_text>Initialize the objectThe `Api` object needs to know your **auth\_token** and the correct path. Here we assume you are using the credentials file in your home directory. For other options see Setup_API_environment.ipynb<jupyter_code># [USER INPUT] specify credentials file profile {cgc, sbg, default}
prof = 'default'

config_file = sbg.Config(profile=prof)
api = sbg.Api(config=config_file)<jupyter_output><empty_output><jupyter_text>Get _some_ projectsWe will start with the basic list call. A **list**-call for projects returns the following *attributes*:* **id**     _Unique_ identifier for the project, generated based on Project Name* **name**   Name of project specified by the user, maybe _non-unique_* **href**   Address1 of the project.A **detail**-call for projects returns the following *attributes*:* **description** The user specified project description* **id**     _Unique_ identifier for the project, generated based on Project Name* **name**   Name of project specified by the user, maybe _non-unique_* **href**   Address1 of the project.* **tags**   List of tags* **created_on** Project creation time* **modified_on** Project modification time* **created_by** User that created the project* **root_folder** ID of the root folder for that project* **billing_group** ID of the billing group for the project* **settings** Dictionary with project settings for storage and task executionAll list API calls will feature pagination, by _default_ 50 items will be returned. We will also show how to specify a different limit and page forward and backwards.  1 This is the address where, by using API you can get this resource<jupyter_code># list (up to) 50 (this is the default for 'limit') projects
my_projects = api.projects.query()

print(' List of project ids and names:')
for project in my_projects:
    print('{} \t {}'.format(project.id, project.name))
# use a short query to highlight pagination
my_projects = api.projects.query(limit=3)

print('   List of first 3 project ids and names:')
for project in my_projects:
    print('{} \t {}'.format(project.id, project.name))
    
# method to retrieve the next page of results
next_page_of_projects = my_projects.next_page()

print('\n   List of next 3 project ids and names:')
for project in next_page_of_projects:
    print('{} \t {}'.format(project.id, project.name))<jupyter_output><empty_output><jupyter_text>NoteFor the pagination above, we used the **.next_page()** and could have also used the **.prior_page()** methods. These will return another list with an limit equal to the prior call and a offset based on the prior call  Get _all_ projectsIt's probably most useful to know all of your projects. Regardless of the query limit, the project object knows the actual total number of projects. We only need to use the **.all** attribute to get all projects.<jupyter_code>existing_projects = my_projects.all()

print('   List of all project ids and names:')
for project in existing_projects:
    print('{} \t {}'.format(project.id, project.name))<jupyter_output><empty_output><jupyter_text>NoteEach time you do **anything** with this _generator object_, it will become exhausted. The next call will be an empty list<jupyter_code># NOTE, after each time you operate on the existing_projects generator object, 
#   it will become an empty list

existing_projects = my_projects.all()
print(existing_projects)
print('\n For the first list() operation, there are %i projects in the generator' \
      % (len(list(existing_projects))))
print(' For the next list() operation, there are %i projects in the generator' % \
      (len(list(existing_projects))))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08939428056743977, 'fraction_numerical': 0.0036027921639270434, 'mean_word_length': 5.195258019525802, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '10619', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1195, 'n_words': 567, 'path': 'Recipes/SBPLAT/projects_listAll.ipynb', 'repo_name': 'sbg/okAPI', 'size': '4441'}