diff --git a/docs/py_jama_rest_client/client.html b/docs/py_jama_rest_client/client.html index 410de68..f62d430 100644 --- a/docs/py_jama_rest_client/client.html +++ b/docs/py_jama_rest_client/client.html @@ -3,29 +3,33 @@ - + py_jama_rest_client.client API documentation - - - - - + + + + + + +
-

py_jama_rest_client.client module

+

Module py_jama_rest_client.client

-Source code + +Expand source code +
import json
 import logging
 
-from .core import Core
+from .core import Core, CoreException
 
 # This is the py_jama_rest_client logger.
 py_jama_rest_client_logger = logging.getLogger('py_jama_rest_client')
@@ -75,8 +79,12 @@ 

py_jama_rest_client.client module

__allowed_results_per_page = 20 # Default is 20, Max is 50. if set to greater than 50, only 50 will items return. - def __init__(self, host_domain, credentials=('username|clientID', 'password|clientSecret'), api_version='/rest/v1/', - oauth=False, verify=True): + def __init__(self, host_domain, + credentials=('username|clientID', 'password|clientSecret'), + api_version='/rest/v1/', + oauth=False, + verify=True, + allowed_results_per_page=20): """Jama Client initializer :rtype: JamaClient :param host_domain: String The domain associated with the Jama Connect host @@ -84,7 +92,12 @@

py_jama_rest_client.client module

:param api_version: valid args are '/rest/[v1|latest|labs]/' :param verify: Defaults to True, Setting this to False will skip SSL Certificate verification""" self.__credentials = credentials - self.__core = Core(host_domain, credentials, api_version=api_version, oauth=oauth, verify=verify) + self.__allowed_results_per_page = allowed_results_per_page + try: + self.__core = Core(host_domain, credentials, api_version=api_version, oauth=oauth, verify=verify) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # Log client creation py_jama_rest_client_logger.info('Created a new JamaClient instance. Domain: {} ' @@ -97,21 +110,26 @@

py_jama_rest_client.client module

Returns: an array of available endpoints for this API """ - response = self.__core.get('') + try: + response = self.__core.get('') + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_baselines(self, project_id): + def get_baselines(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of Baseline objects Args: project_id: the Id of the project to fetch baselines for + allowed_results_per_page: number of results per page Returns: a list of Baseline objects """ resource_path = 'baselines' params = {'project': project_id} - baseline_data = self.__get_all(resource_path, params=params) + baseline_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return baseline_data def get_baseline(self, baseline_id): @@ -124,37 +142,42 @@

py_jama_rest_client.client module

""" resource_path = 'baselines/' + str(baseline_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_baselines_versioneditems(self, baseline_id): + def get_baselines_versioneditems(self, baseline_id, allowed_results_per_page=__allowed_results_per_page): """ Get all baseline items in a baseline with the specified ID Args: baseline_id: The id of the baseline to fetch items for. - + allowed_results_per_page: Number of results per page Returns: A list of versioned items belonging to the baseline """ resource_path = 'baselines/' + str(baseline_id) + '/versioneditems' - baseline_items = self.__get_all(resource_path) + baseline_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return baseline_items - def get_projects(self): + def get_projects(self, allowed_results_per_page=__allowed_results_per_page): """This method will return all projects as JSON object :return: JSON Array of Item Objects. """ resource_path = 'projects' - project_data = self.__get_all(resource_path) + project_data = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return project_data - def get_filter_results(self, filter_id, project_id=None): + def get_filter_results(self, filter_id, project_id=None, allowed_results_per_page=__allowed_results_per_page): """ Get all results items for the filter with the specified ID Args: filter_id: The ID of the filter to fetch the results for. project_id: Use this only for filters that run on any project, where projectScope is CURRENT + allowed_results_per_page: Number of results per page Returns: A List of items that match the filter. @@ -164,21 +187,22 @@

py_jama_rest_client.client module

params = None if project_id is not None: params = {'project': str(project_id)} - filter_results = self.__get_all(resource_path, params=params) + filter_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return filter_results - def get_items(self, project_id): + def get_items(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ This method will return all items in the specified project. Args: project_id: the project ID + allowed_results_per_page: number of results per page Returns: a Json array of item objects """ resource_path = 'items' params = {'project': project_id} - item_data = self.__get_all(resource_path, params=params) + item_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return item_data def get_item(self, item_id): @@ -191,7 +215,11 @@

py_jama_rest_client.client module

""" resource_path = 'items/' + str(item_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -206,7 +234,11 @@

py_jama_rest_client.client module

""" resource_path = 'items/' + str(item_id) + '/lock' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -226,9 +258,28 @@

py_jama_rest_client.client module

} resource_path = 'items/' + str(item_id) + '/lock' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) + def get_item_tags(self, item_id, allowed_results_per_page=__allowed_results_per_page): + """ + Return all tags for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + allowed_results_per_page: number of results + + Returns: a dictionary object representing the item's tags + + """ + resource_path = 'items/' + str(item_id) + '/tags' + item_tags = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return item_tags + def get_attachment(self, attachment_id): """ This method will return a singular attachment of a specified attachment id @@ -239,28 +290,69 @@

py_jama_rest_client.client module

""" resource_path = 'attachments/' + str(attachment_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_abstract_items_from_doc_key(self, doc_key_list): + def get_abstract_items_from_doc_key(self, doc_key_list, allowed_results_per_page=__allowed_results_per_page): """ DEPRECATED INSTEAD USE get_abstract_items below. This method will take in a list of document keys and return an array of JSON Objects associated with the document keys.""" resource_path = 'abstractitems' params = {'documentKey': doc_key_list} - abstract_items = self.__get_all(resource_path, params=params) + abstract_items = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return abstract_items - def get_relationship_types(self): + def get_relationship_rule_sets(self): + """ + This method will return all relationship rule sets across all projects of the Jama Connect instance. + + Returns: An array of dictionary objects representing a rule set and its associated rules + + """ + resource_path = 'relationshiprulesets/' + rule_sets = self.__get_all(resource_path) + return rule_sets + + def get_relationship_rule_set(self, id): + """ + This method will return the relationship rule sets by id. + + Returns: A dictionary object representing a rule set and its associated rules + + """ + resource_path = 'relationshiprulesets/' + str(id) + response = self.__core.get(resource_path) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_relationship_rule_set_projects(self, id): + """ + This method will return the projects that have a given relationship rule set defined. + + Returns: An array of the dictionary objects representing the projects with a given rule set assigned + + """ + resource_path = 'relationshiprulesets/' + str(id) + '/projects' + projects = self.__get_all(resource_path) + return projects + + def get_relationship_types(self, allowed_results_per_page=__allowed_results_per_page): """ This method will return all relationship types of the across all projects of the Jama Connect instance. + Args: + allowed_results_per_page: Number of results per page + Returns: An array of dictionary objects """ resource_path = 'relationshiptypes/' - item_types = self.__get_all(resource_path) + item_types = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return item_types def get_relationship_type(self, relationship_type_id): @@ -274,19 +366,26 @@

py_jama_rest_client.client module

""" resource_path = 'relationshiptypes/' + str(relationship_type_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_item_types(self): + def get_item_types(self, allowed_results_per_page=__allowed_results_per_page): """ This method will return all item types of the across all projects of the Jama Connect instance. + Args: + allowed_results_per_page: Number of results per page + Returns: An array of dictionary objects """ resource_path = 'itemtypes/' - item_types = self.__get_all(resource_path) + item_types = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return item_types def get_item_type(self, item_type_id): @@ -300,23 +399,28 @@

py_jama_rest_client.client module

""" resource_path = 'itemtypes/' + str(item_type_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_items_synceditems(self, item_id): + def get_items_synceditems(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Get all synchronized items for the item with the specified ID Args: item_id: The API id of the item being + allowed_results_per_page: Number of results per page Returns: A list of JSON Objects representing the items that are in the same synchronization group as the specified item. """ resource_path = 'items/' + str(item_id) + '/synceditems' - synced_items = self.__get_all(resource_path) + synced_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return synced_items def get_items_synceditems_status(self, item_id, synced_item_id): @@ -331,19 +435,121 @@

py_jama_rest_client.client module

""" resource_path = 'items/' + str(item_id) + '/synceditems/' + str(synced_item_id) + '/syncstatus' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_item_versions(self, item_id): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + + Returns: JSON array with all versions for the item + """ + resource_path = 'items/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path) + return versions + + def get_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_item_versions(self, item_id, allowed_results_per_page=__allowed_results_per_page): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + allowed_results_per_page: number of results per page + + Returns: JSON array with all versions for the item + """ + resource_path = 'items/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return versions + + def get_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + response = self.__core.get(resource_path) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' response = self.__core.get(resource_path) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_pick_lists(self): + def get_pick_lists(self, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the pick lists + Args: + allowed_results_per_page: number of results per page + Returns: an array of dictionary objects """ resource_path = 'picklists/' - pick_lists = self.__get_all(resource_path) + pick_lists = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return pick_lists def get_pick_list(self, pick_list_id): @@ -357,21 +563,26 @@

py_jama_rest_client.client module

""" resource_path = 'picklists/' + str(pick_list_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_pick_list_options(self, pick_list_id): + def get_pick_list_options(self, pick_list_id, allowed_results_per_page=__allowed_results_per_page): """ Gets all all the picklist options for a single picklist Args: pick_list_id: the api id of the picklist to fetch options for. + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the picklist options. """ resource_path = 'picklists/' + str(pick_list_id) + '/options' - pick_list_options = self.__get_all(resource_path) + pick_list_options = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return pick_list_options def get_pick_list_option(self, pick_list_option_id): @@ -384,23 +595,29 @@

py_jama_rest_client.client module

""" resource_path = 'picklistoptions/' + str(pick_list_option_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_relationships(self, project_id): + def get_relationships(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all relationships of a specified project Args: project_id: the api project id of a project + allowed_results_per_page: number of results per page Returns: a list of dictionary objects that represents a relationships """ resource_path = 'relationships' params = {'project': project_id} - relationship_data = self.__get_all(resource_path, params=params) + relationship_data = self.__get_all(resource_path, params=params, + allowed_results_per_page=allowed_results_per_page) return relationship_data def get_relationship(self, relationship_id): @@ -414,7 +631,11 @@

py_jama_rest_client.client module

""" resource_path = 'relationships/' + str(relationship_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -481,51 +702,124 @@

py_jama_rest_client.client module

abstract_items = self.__get_all(resource_path, params=params) return abstract_items - def get_item_children(self, item_id): + def get_abstract_item(self, item_id): + """ + This method will return an item, test plan, test cycle, test run, or attachment with the specified ID + Args: + item_id: the item id of the item to fetch + + Returns: a dictonary object representing the abstract item + + """ + resource_path = 'abstractitems/' + str(item_id) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_abstract_item_versions(self, item_id): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + + Returns: JSON array with all versions for the item + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path) + return versions + + def get_abtract_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_abstract_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + + def get_item_children(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ This method will return list of the child items of the item passed to the function. Args: item_id: (int) The id of the item for which children items should be fetched + allowed_results_per_page: Number of results per page Returns: a List of Objects that represent the children of the item passed in. """ resource_path = 'items/' + str(item_id) + '/children' - child_items = self.__get_all(resource_path) + child_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return child_items - def get_testruns(self, test_cycle_id): + def get_testruns(self, test_cycle_id, allowed_results_per_page=__allowed_results_per_page): """This method will return all test runs associated with the specified test cycle. Test runs will be returned as a list of json objects.""" resource_path = 'testcycles/' + str(test_cycle_id) + '/testruns' - testrun_data = self.__get_all(resource_path) + testrun_data = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return testrun_data - def get_items_upstream_relationships(self, item_id): + def get_items_upstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the upstream relationships for the item with the specified ID. Args: item_id: the api id of the item + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the upstream relationships for the item. """ resource_path = 'items/' + str(item_id) + '/upstreamrelationships' - return self.__get_all(resource_path) + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) - def get_items_downstream_related(self, item_id): + def get_items_downstream_related(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the downstream related items for the item with the specified ID. Args: item_id: the api id of the item to fetch downstream items for + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the downstream related items for the specified item. """ resource_path = 'items/' + str(item_id) + '/downstreamrelated' - return self.__get_all(resource_path) + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) - def get_items_downstream_relationships(self, item_id): + def get_items_downstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the downstream relationships for the item with the specified ID. @@ -536,28 +830,57 @@

py_jama_rest_client.client module

""" resource_path = 'items/' + str(item_id) + '/downstreamrelationships' + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + + def get_items_upstream_related(self, item_id): + """ + Returns a list of all the upstream related items for the item with the specified ID. + + Args: + item_id: the api id of the item to fetch upstream items for + + Returns: an array of dictionary objects that represent the upstream related items for the specified item. + + """ + resource_path = 'items/' + str(item_id) + '/upstreamrelated' + return self.__get_all(resource_path) + + def get_item_workflow_transitions(self, item_id): + """ + Get all valid workflow transitions that can be made with the specified id + + Args: + item_id: the api id of the item + allowed_results_per_page: number of results per page + + Returns: an array of dictionary objects that represent the workflow transitions for the item. + + """ + resource_path = 'items/' + str(item_id) + '/workflowtransitionoptions' return self.__get_all(resource_path) - def get_tags(self, project): + def get_tags(self, project, allowed_results_per_page=__allowed_results_per_page): """ Get all tags for the project with the specified id Args: project: The API ID of the project to fetch tags for. + allowed_results_per_page: Number of results per page Returns: A Json Array that contains all the tag data for the specified project. """ resource_path = 'tags' params = {'project': project} - tag_data = self.__get_all(resource_path, params=params) + tag_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_data - def get_tagged_items(self, tag_id): + def get_tagged_items(self, tag_id, allowed_results_per_page=__allowed_results_per_page): """ Get all items tagged with the specified ID Args: tag_id: The ID of the tag to fetch the results for. + allowed_results_per_page: Number of results per page Returns: A List of items that match the tag. @@ -565,18 +888,57 @@

py_jama_rest_client.client module

""" resource_path = 'tags/' + str(tag_id) + '/items' params = None - tag_results = self.__get_all(resource_path, params=params) + tag_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_results - def get_users(self): + def get_item_links(self, item_id): + """ + This method will return all links in the specified item. + Args: + item_id: the item ID + + Returns: a Json object with the links present in the item specified + + """ + resource_path = 'items/' + str(item_id) + '/links' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_filter_results_count(self, filter_id): + """ + This method will return count of items found through the specified filter. + Args: + filter_id: the filter ID + + Returns: a count of the items matched with the filter + + """ + resource_path = 'filters/' + str(filter_id) + '/count' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_users(self, allowed_results_per_page=__allowed_results_per_page): """ Gets a list of all active users visible to the current user + Args: + allowed_results_per_page: Number of results per page + Returns: JSON array """ resource_path = 'users/' - users = self.__get_all(resource_path) + users = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return users def get_user(self, user_id): @@ -590,7 +952,11 @@

py_jama_rest_client.client module

""" resource_path = 'users/' + str(user_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data'] def get_current_user(self): @@ -601,7 +967,11 @@

py_jama_rest_client.client module

""" resource_path = 'users/current' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data'] def get_test_cycle(self, test_cycle_id): @@ -615,7 +985,11 @@

py_jama_rest_client.client module

""" resource_path = 'testcycles/' + str(test_cycle_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -629,7 +1003,11 @@

py_jama_rest_client.client module

Returns: The success status code. """ resource_path = 'items/' + str(item_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -644,7 +1022,11 @@

py_jama_rest_client.client module

""" resource_path = 'relationships/' + str(relationship_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -672,7 +1054,11 @@

py_jama_rest_client.client module

data = json.dumps(patches) # Make the API Call - response = self.__core.patch(resource_path, data=data, headers=headers) + try: + response = self.__core.patch(resource_path, data=data, headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # validate response JamaClient.__handle_response_status(response) @@ -711,7 +1097,11 @@

py_jama_rest_client.client module

} resource_path = 'users/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -730,7 +1120,11 @@

py_jama_rest_client.client module

'project': project } headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -770,7 +1164,11 @@

py_jama_rest_client.client module

} # Make the API Call - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # Validate response JamaClient.__handle_response_status(response) @@ -804,7 +1202,11 @@

py_jama_rest_client.client module

params['setGlobalIdManually'] = True headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -823,7 +1225,11 @@

py_jama_rest_client.client module

} resource_path = 'items/' + str(item_id) + '/tags' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -843,7 +1249,11 @@

py_jama_rest_client.client module

resource_path = 'items/' + str(pool_item) + '/synceditems' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -866,7 +1276,11 @@

py_jama_rest_client.client module

body['relationshipType'] = relationship_type resource_path = 'relationships/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -880,7 +1294,11 @@

py_jama_rest_client.client module

body = {"attachment": attachment_id} resource_path = 'items/' + str(item_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -901,7 +1319,11 @@

py_jama_rest_client.client module

resource_path = 'projects/' + str(project_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -927,7 +1349,11 @@

py_jama_rest_client.client module

} resource_path = 'items/' + str(item_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) def put_attachments_file(self, attachment_id, file_path): @@ -940,8 +1366,11 @@

py_jama_rest_client.client module

resource_path = 'attachments/' + str(attachment_id) + '/file' with open(file_path, 'rb') as f: files = {'file': f} - response = self.__core.put(resource_path, files=files) - + try: + response = self.__core.put(resource_path, files=files) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) self.__handle_response_status(response) return response.status_code @@ -976,7 +1405,12 @@

py_jama_rest_client.client module

} resource_path = 'users/' + str(user_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + raise APIException return self.__handle_response_status(response) def put_user_active(self, user_id, is_active): @@ -994,54 +1428,68 @@

py_jama_rest_client.client module

} resource_path = 'users/' + str(user_id) + '/active' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) def put_test_run(self, test_run_id, data=None): """ This method will post a test run to Jama through the API""" resource_path = 'testruns/' + str(test_run_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=data, headers=headers) + try: + response = self.__core.put(resource_path, data=data, headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) - def __get_all(self, resource, params=None, **kwargs): + def __get_all(self, resource, params=None, allowed_results_per_page=__allowed_results_per_page, **kwargs): """This method will get all of the resources specified by the resource parameter, if an id or some other parameter is required for the resource, include it in the params parameter. Returns a single JSON array with all of the retrieved items.""" + if allowed_results_per_page < 1 or allowed_results_per_page > 50: + raise ValueError("Allowed results per page must be between 1 and 50") + start_index = 0 - result_count = -1 allowed_results_per_page = 20 + total_results = float("inf") data = [] - while result_count != 0: + while len(data) < total_results: page_response = self.__get_page(resource, start_index, params=params, **kwargs) page_json = page_response.json() page_info = page_json['meta']['pageInfo'] start_index = page_info['startIndex'] + allowed_results_per_page - result_count = page_info['resultCount'] - + total_results = page_info.get('totalResults') page_data = page_json.get('data') data.extend(page_data) return data - def __get_page(self, resource, start_at, params=None, **kwargs): + def __get_page(self, resource, start_at, params=None, allowed_results_per_page=__allowed_results_per_page, **kwargs): """This method will return one page of results from the specified resource type. Pass any needed parameters along The response object will be returned""" parameters = { 'startAt': start_at, - 'maxResults': self.__allowed_results_per_page + 'maxResults': allowed_results_per_page } if params is not None: for k, v in params.items(): parameters[k] = v - response = self.__core.get(resource, params=parameters, **kwargs) + try: + response = self.__core.get(resource, params=parameters, **kwargs) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response @@ -1111,7 +1559,14 @@

py_jama_rest_client.client module

py_jama_rest_client_logger.error('{} error. {}'.format(status, response.reason)) raise APIException("{} error".format(status), status_code=status, - reason=response.reason)
+ reason=response.reason) + + def set_allowed_results_per_page(self, allowed_results_per_page): + self.__allowed_results_per_page = allowed_results_per_page + + def get_allowed_results_per_page(self): + return self.__allowed_results_per_page +
@@ -1125,33 +1580,35 @@

Classes

class APIClientException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is thrown whenever a unknown 400 error is encountered.

+

This exception is thrown whenever a unknown 400 error is encountered.

-Source code + +Expand source code +
class APIClientException(APIException):
     """This exception is thrown whenever a unknown 400 error is encountered."""
     pass
-

Inherited members

-
class APIException -(ancestors: builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This is the base class for all exceptions raised by the JamaClient

+

This is the base class for all exceptions raised by the JamaClient

-Source code + +Expand source code +
class APIException(Exception):
     """This is the base class for all exceptions raised by the JamaClient"""
 
@@ -1160,89 +1617,90 @@ 

Inherited members

self.status_code = status_code self.reason = reason
+

Ancestors

+
    +
  • builtins.Exception
  • +
  • builtins.BaseException
  • +

Subclasses

-

Methods

-
-
-def __init__(self, message, status_code=None, reason=None) -
-
-

Initialize self. -See help(type(self)) for accurate signature.

-
-Source code -
def __init__(self, message, status_code=None, reason=None):
-    super(APIException, self).__init__(message)
-    self.status_code = status_code
-    self.reason = reason
-
-
-
class APIServerException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is thrown whenever an unknown 500 response is encountered.

+

This exception is thrown whenever an unknown 500 response is encountered.

-Source code + +Expand source code +
class APIServerException(APIException):
     """This exception is thrown whenever an unknown 500 response is encountered."""
     pass
-

Inherited members

+

Ancestors

class AlreadyExistsException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is thrown when the API returns a 400 response with a message that the resource already exists.

+

This exception is thrown when the API returns a 400 response with a message that the resource already exists.

-Source code + +Expand source code +
class AlreadyExistsException(APIException):
     """This exception is thrown when the API returns a 400 response with a message that the resource already exists."""
     pass
-

Inherited members

-
class JamaClient +(host_domain, credentials=('username|clientID', 'password|clientSecret'), api_version='/rest/v1/', oauth=False, verify=True, allowed_results_per_page=20)
-

A class to abstract communication with the Jama Connect API

+

A class to abstract communication with the Jama Connect API

+

Jama Client initializer +:rtype: JamaClient +:param host_domain: String The domain associated with the Jama Connect host +:param credentials: the user name and password as a tuple or client id and client secret if using Oauth. +:param api_version: valid args are '/rest/[v1|latest|labs]/' +:param verify: Defaults to True, Setting this to False will skip SSL Certificate verification

-Source code + +Expand source code +
class JamaClient:
     """A class to abstract communication with the Jama Connect API"""
 
     __allowed_results_per_page = 20  # Default is 20, Max is 50. if set to greater than 50, only 50 will items return.
 
-    def __init__(self, host_domain, credentials=('username|clientID', 'password|clientSecret'), api_version='/rest/v1/',
-                 oauth=False, verify=True):
+    def __init__(self, host_domain,
+                 credentials=('username|clientID', 'password|clientSecret'),
+                 api_version='/rest/v1/',
+                 oauth=False,
+                 verify=True,
+                 allowed_results_per_page=20):
         """Jama Client initializer
         :rtype: JamaClient
         :param host_domain: String The domain associated with the Jama Connect host
@@ -1250,7 +1708,12 @@ 

Inherited members

:param api_version: valid args are '/rest/[v1|latest|labs]/' :param verify: Defaults to True, Setting this to False will skip SSL Certificate verification""" self.__credentials = credentials - self.__core = Core(host_domain, credentials, api_version=api_version, oauth=oauth, verify=verify) + self.__allowed_results_per_page = allowed_results_per_page + try: + self.__core = Core(host_domain, credentials, api_version=api_version, oauth=oauth, verify=verify) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # Log client creation py_jama_rest_client_logger.info('Created a new JamaClient instance. Domain: {} ' @@ -1263,21 +1726,26 @@

Inherited members

Returns: an array of available endpoints for this API """ - response = self.__core.get('') + try: + response = self.__core.get('') + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_baselines(self, project_id): + def get_baselines(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of Baseline objects Args: project_id: the Id of the project to fetch baselines for + allowed_results_per_page: number of results per page Returns: a list of Baseline objects """ resource_path = 'baselines' params = {'project': project_id} - baseline_data = self.__get_all(resource_path, params=params) + baseline_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return baseline_data def get_baseline(self, baseline_id): @@ -1290,37 +1758,42 @@

Inherited members

""" resource_path = 'baselines/' + str(baseline_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_baselines_versioneditems(self, baseline_id): + def get_baselines_versioneditems(self, baseline_id, allowed_results_per_page=__allowed_results_per_page): """ Get all baseline items in a baseline with the specified ID Args: baseline_id: The id of the baseline to fetch items for. - + allowed_results_per_page: Number of results per page Returns: A list of versioned items belonging to the baseline """ resource_path = 'baselines/' + str(baseline_id) + '/versioneditems' - baseline_items = self.__get_all(resource_path) + baseline_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return baseline_items - def get_projects(self): + def get_projects(self, allowed_results_per_page=__allowed_results_per_page): """This method will return all projects as JSON object :return: JSON Array of Item Objects. """ resource_path = 'projects' - project_data = self.__get_all(resource_path) + project_data = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return project_data - def get_filter_results(self, filter_id, project_id=None): + def get_filter_results(self, filter_id, project_id=None, allowed_results_per_page=__allowed_results_per_page): """ Get all results items for the filter with the specified ID Args: filter_id: The ID of the filter to fetch the results for. project_id: Use this only for filters that run on any project, where projectScope is CURRENT + allowed_results_per_page: Number of results per page Returns: A List of items that match the filter. @@ -1330,21 +1803,22 @@

Inherited members

params = None if project_id is not None: params = {'project': str(project_id)} - filter_results = self.__get_all(resource_path, params=params) + filter_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return filter_results - def get_items(self, project_id): + def get_items(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ This method will return all items in the specified project. Args: project_id: the project ID + allowed_results_per_page: number of results per page Returns: a Json array of item objects """ resource_path = 'items' params = {'project': project_id} - item_data = self.__get_all(resource_path, params=params) + item_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return item_data def get_item(self, item_id): @@ -1357,7 +1831,11 @@

Inherited members

""" resource_path = 'items/' + str(item_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -1372,7 +1850,11 @@

Inherited members

""" resource_path = 'items/' + str(item_id) + '/lock' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -1392,9 +1874,28 @@

Inherited members

} resource_path = 'items/' + str(item_id) + '/lock' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) + def get_item_tags(self, item_id, allowed_results_per_page=__allowed_results_per_page): + """ + Return all tags for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + allowed_results_per_page: number of results + + Returns: a dictionary object representing the item's tags + + """ + resource_path = 'items/' + str(item_id) + '/tags' + item_tags = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return item_tags + def get_attachment(self, attachment_id): """ This method will return a singular attachment of a specified attachment id @@ -1405,55 +1906,103 @@

Inherited members

""" resource_path = 'attachments/' + str(attachment_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_abstract_items_from_doc_key(self, doc_key_list): + def get_abstract_items_from_doc_key(self, doc_key_list, allowed_results_per_page=__allowed_results_per_page): """ DEPRECATED INSTEAD USE get_abstract_items below. This method will take in a list of document keys and return an array of JSON Objects associated with the document keys.""" resource_path = 'abstractitems' params = {'documentKey': doc_key_list} - abstract_items = self.__get_all(resource_path, params=params) + abstract_items = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return abstract_items - def get_relationship_types(self): + def get_relationship_rule_sets(self): """ - This method will return all relationship types of the across all projects of the Jama Connect instance. + This method will return all relationship rule sets across all projects of the Jama Connect instance. - Returns: An array of dictionary objects + Returns: An array of dictionary objects representing a rule set and its associated rules """ - resource_path = 'relationshiptypes/' - item_types = self.__get_all(resource_path) - return item_types + resource_path = 'relationshiprulesets/' + rule_sets = self.__get_all(resource_path) + return rule_sets - def get_relationship_type(self, relationship_type_id): + def get_relationship_rule_set(self, id): """ - Gets relationship type information for a specific relationship type id. - - Args: - relationship_type_id: The api id of the item type to fetch + This method will return the relationship rule sets by id. - Returns: JSON object + Returns: A dictionary object representing a rule set and its associated rules """ - resource_path = 'relationshiptypes/' + str(relationship_type_id) + resource_path = 'relationshiprulesets/' + str(id) response = self.__core.get(resource_path) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_item_types(self): + def get_relationship_rule_set_projects(self, id): """ - This method will return all item types of the across all projects of the Jama Connect instance. + This method will return the projects that have a given relationship rule set defined. - Returns: An array of dictionary objects + Returns: An array of the dictionary objects representing the projects with a given rule set assigned """ - resource_path = 'itemtypes/' - item_types = self.__get_all(resource_path) - return item_types + resource_path = 'relationshiprulesets/' + str(id) + '/projects' + projects = self.__get_all(resource_path) + return projects + + def get_relationship_types(self, allowed_results_per_page=__allowed_results_per_page): + """ + This method will return all relationship types of the across all projects of the Jama Connect instance. + + Args: + allowed_results_per_page: Number of results per page + + Returns: An array of dictionary objects + + """ + resource_path = 'relationshiptypes/' + item_types = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return item_types + + def get_relationship_type(self, relationship_type_id): + """ + Gets relationship type information for a specific relationship type id. + + Args: + relationship_type_id: The api id of the item type to fetch + + Returns: JSON object + + """ + resource_path = 'relationshiptypes/' + str(relationship_type_id) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_item_types(self, allowed_results_per_page=__allowed_results_per_page): + """ + This method will return all item types of the across all projects of the Jama Connect instance. + + Args: + allowed_results_per_page: Number of results per page + + Returns: An array of dictionary objects + + """ + resource_path = 'itemtypes/' + item_types = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return item_types def get_item_type(self, item_type_id): """ @@ -1466,23 +2015,28 @@

Inherited members

""" resource_path = 'itemtypes/' + str(item_type_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_items_synceditems(self, item_id): + def get_items_synceditems(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Get all synchronized items for the item with the specified ID Args: item_id: The API id of the item being + allowed_results_per_page: Number of results per page Returns: A list of JSON Objects representing the items that are in the same synchronization group as the specified item. """ resource_path = 'items/' + str(item_id) + '/synceditems' - synced_items = self.__get_all(resource_path) + synced_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return synced_items def get_items_synceditems_status(self, item_id, synced_item_id): @@ -1497,19 +2051,121 @@

Inherited members

""" resource_path = 'items/' + str(item_id) + '/synceditems/' + str(synced_item_id) + '/syncstatus' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_item_versions(self, item_id): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + + Returns: JSON array with all versions for the item + """ + resource_path = 'items/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path) + return versions + + def get_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_item_versions(self, item_id, allowed_results_per_page=__allowed_results_per_page): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + allowed_results_per_page: number of results per page + + Returns: JSON array with all versions for the item + """ + resource_path = 'items/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + return versions + + def get_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + response = self.__core.get(resource_path) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' response = self.__core.get(resource_path) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_pick_lists(self): + def get_pick_lists(self, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the pick lists + Args: + allowed_results_per_page: number of results per page + Returns: an array of dictionary objects """ resource_path = 'picklists/' - pick_lists = self.__get_all(resource_path) + pick_lists = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return pick_lists def get_pick_list(self, pick_list_id): @@ -1523,21 +2179,26 @@

Inherited members

""" resource_path = 'picklists/' + str(pick_list_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_pick_list_options(self, pick_list_id): + def get_pick_list_options(self, pick_list_id, allowed_results_per_page=__allowed_results_per_page): """ Gets all all the picklist options for a single picklist Args: pick_list_id: the api id of the picklist to fetch options for. + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the picklist options. """ resource_path = 'picklists/' + str(pick_list_id) + '/options' - pick_list_options = self.__get_all(resource_path) + pick_list_options = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return pick_list_options def get_pick_list_option(self, pick_list_option_id): @@ -1550,23 +2211,29 @@

Inherited members

""" resource_path = 'picklistoptions/' + str(pick_list_option_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] - def get_relationships(self, project_id): + def get_relationships(self, project_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all relationships of a specified project Args: project_id: the api project id of a project + allowed_results_per_page: number of results per page Returns: a list of dictionary objects that represents a relationships """ resource_path = 'relationships' params = {'project': project_id} - relationship_data = self.__get_all(resource_path, params=params) + relationship_data = self.__get_all(resource_path, params=params, + allowed_results_per_page=allowed_results_per_page) return relationship_data def get_relationship(self, relationship_id): @@ -1580,7 +2247,11 @@

Inherited members

""" resource_path = 'relationships/' + str(relationship_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -1647,51 +2318,124 @@

Inherited members

abstract_items = self.__get_all(resource_path, params=params) return abstract_items - def get_item_children(self, item_id): + def get_abstract_item(self, item_id): + """ + This method will return an item, test plan, test cycle, test run, or attachment with the specified ID + Args: + item_id: the item id of the item to fetch + + Returns: a dictonary object representing the abstract item + + """ + resource_path = 'abstractitems/' + str(item_id) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_abstract_item_versions(self, item_id): + """ + Get all versions for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + + Returns: JSON array with all versions for the item + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions' + versions = self.__get_all(resource_path) + return versions + + def get_abtract_item_version(self, item_id, version_num): + """ + Get the numbered version for the item with the specified ID + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the numbered version + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_abstract_versioned_item(self, item_id, version_num): + """ + Get the snapshot of the item at the specified version + + Args: + item_id: the item id of the item to fetch + version_num: the version number for the item + + Returns: a dictionary object representing the versioned item + """ + resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + + def get_item_children(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ This method will return list of the child items of the item passed to the function. Args: item_id: (int) The id of the item for which children items should be fetched + allowed_results_per_page: Number of results per page Returns: a List of Objects that represent the children of the item passed in. """ resource_path = 'items/' + str(item_id) + '/children' - child_items = self.__get_all(resource_path) + child_items = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return child_items - def get_testruns(self, test_cycle_id): + def get_testruns(self, test_cycle_id, allowed_results_per_page=__allowed_results_per_page): """This method will return all test runs associated with the specified test cycle. Test runs will be returned as a list of json objects.""" resource_path = 'testcycles/' + str(test_cycle_id) + '/testruns' - testrun_data = self.__get_all(resource_path) + testrun_data = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return testrun_data - def get_items_upstream_relationships(self, item_id): + def get_items_upstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the upstream relationships for the item with the specified ID. Args: item_id: the api id of the item + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the upstream relationships for the item. """ resource_path = 'items/' + str(item_id) + '/upstreamrelationships' - return self.__get_all(resource_path) + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) - def get_items_downstream_related(self, item_id): + def get_items_downstream_related(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the downstream related items for the item with the specified ID. Args: item_id: the api id of the item to fetch downstream items for + allowed_results_per_page: number of results per page Returns: an array of dictionary objects that represent the downstream related items for the specified item. """ resource_path = 'items/' + str(item_id) + '/downstreamrelated' - return self.__get_all(resource_path) + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) - def get_items_downstream_relationships(self, item_id): + def get_items_downstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page): """ Returns a list of all the downstream relationships for the item with the specified ID. @@ -1702,28 +2446,57 @@

Inherited members

""" resource_path = 'items/' + str(item_id) + '/downstreamrelationships' + return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) + + def get_items_upstream_related(self, item_id): + """ + Returns a list of all the upstream related items for the item with the specified ID. + + Args: + item_id: the api id of the item to fetch upstream items for + + Returns: an array of dictionary objects that represent the upstream related items for the specified item. + + """ + resource_path = 'items/' + str(item_id) + '/upstreamrelated' + return self.__get_all(resource_path) + + def get_item_workflow_transitions(self, item_id): + """ + Get all valid workflow transitions that can be made with the specified id + + Args: + item_id: the api id of the item + allowed_results_per_page: number of results per page + + Returns: an array of dictionary objects that represent the workflow transitions for the item. + + """ + resource_path = 'items/' + str(item_id) + '/workflowtransitionoptions' return self.__get_all(resource_path) - def get_tags(self, project): + def get_tags(self, project, allowed_results_per_page=__allowed_results_per_page): """ Get all tags for the project with the specified id Args: project: The API ID of the project to fetch tags for. + allowed_results_per_page: Number of results per page Returns: A Json Array that contains all the tag data for the specified project. """ resource_path = 'tags' params = {'project': project} - tag_data = self.__get_all(resource_path, params=params) + tag_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_data - def get_tagged_items(self, tag_id): + def get_tagged_items(self, tag_id, allowed_results_per_page=__allowed_results_per_page): """ Get all items tagged with the specified ID Args: tag_id: The ID of the tag to fetch the results for. + allowed_results_per_page: Number of results per page Returns: A List of items that match the tag. @@ -1731,18 +2504,57 @@

Inherited members

""" resource_path = 'tags/' + str(tag_id) + '/items' params = None - tag_results = self.__get_all(resource_path, params=params) + tag_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_results - def get_users(self): + def get_item_links(self, item_id): + """ + This method will return all links in the specified item. + Args: + item_id: the item ID + + Returns: a Json object with the links present in the item specified + + """ + resource_path = 'items/' + str(item_id) + '/links' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_filter_results_count(self, filter_id): + """ + This method will return count of items found through the specified filter. + Args: + filter_id: the filter ID + + Returns: a count of the items matched with the filter + + """ + resource_path = 'filters/' + str(filter_id) + '/count' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_users(self, allowed_results_per_page=__allowed_results_per_page): """ Gets a list of all active users visible to the current user + Args: + allowed_results_per_page: Number of results per page + Returns: JSON array """ resource_path = 'users/' - users = self.__get_all(resource_path) + users = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page) return users def get_user(self, user_id): @@ -1756,7 +2568,11 @@

Inherited members

""" resource_path = 'users/' + str(user_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data'] def get_current_user(self): @@ -1767,7 +2583,11 @@

Inherited members

""" resource_path = 'users/current' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data'] def get_test_cycle(self, test_cycle_id): @@ -1781,7 +2601,11 @@

Inherited members

""" resource_path = 'testcycles/' + str(test_cycle_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data'] @@ -1795,7 +2619,11 @@

Inherited members

Returns: The success status code. """ resource_path = 'items/' + str(item_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -1810,7 +2638,11 @@

Inherited members

""" resource_path = 'relationships/' + str(relationship_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -1838,7 +2670,11 @@

Inherited members

data = json.dumps(patches) # Make the API Call - response = self.__core.patch(resource_path, data=data, headers=headers) + try: + response = self.__core.patch(resource_path, data=data, headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # validate response JamaClient.__handle_response_status(response) @@ -1877,7 +2713,11 @@

Inherited members

} resource_path = 'users/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -1896,7 +2736,11 @@

Inherited members

'project': project } headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -1936,7 +2780,11 @@

Inherited members

} # Make the API Call - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # Validate response JamaClient.__handle_response_status(response) @@ -1970,7 +2818,11 @@

Inherited members

params['setGlobalIdManually'] = True headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -1989,7 +2841,11 @@

Inherited members

} resource_path = 'items/' + str(item_id) + '/tags' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -2009,7 +2865,11 @@

Inherited members

resource_path = 'items/' + str(pool_item) + '/synceditems' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -2032,7 +2892,11 @@

Inherited members

body['relationshipType'] = relationship_type resource_path = 'relationships/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -2046,7 +2910,11 @@

Inherited members

body = {"attachment": attachment_id} resource_path = 'items/' + str(item_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code @@ -2067,7 +2935,11 @@

Inherited members

resource_path = 'projects/' + str(project_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id'] @@ -2093,7 +2965,11 @@

Inherited members

} resource_path = 'items/' + str(item_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) def put_attachments_file(self, attachment_id, file_path): @@ -2106,8 +2982,11 @@

Inherited members

resource_path = 'attachments/' + str(attachment_id) + '/file' with open(file_path, 'rb') as f: files = {'file': f} - response = self.__core.put(resource_path, files=files) - + try: + response = self.__core.put(resource_path, files=files) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) self.__handle_response_status(response) return response.status_code @@ -2142,7 +3021,12 @@

Inherited members

} resource_path = 'users/' + str(user_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + raise APIException return self.__handle_response_status(response) def put_user_active(self, user_id, is_active): @@ -2160,54 +3044,68 @@

Inherited members

} resource_path = 'users/' + str(user_id) + '/active' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) def put_test_run(self, test_run_id, data=None): """ This method will post a test run to Jama through the API""" resource_path = 'testruns/' + str(test_run_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=data, headers=headers) + try: + response = self.__core.put(resource_path, data=data, headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response) - def __get_all(self, resource, params=None, **kwargs): + def __get_all(self, resource, params=None, allowed_results_per_page=__allowed_results_per_page, **kwargs): """This method will get all of the resources specified by the resource parameter, if an id or some other parameter is required for the resource, include it in the params parameter. Returns a single JSON array with all of the retrieved items.""" + if allowed_results_per_page < 1 or allowed_results_per_page > 50: + raise ValueError("Allowed results per page must be between 1 and 50") + start_index = 0 - result_count = -1 allowed_results_per_page = 20 + total_results = float("inf") data = [] - while result_count != 0: + while len(data) < total_results: page_response = self.__get_page(resource, start_index, params=params, **kwargs) page_json = page_response.json() page_info = page_json['meta']['pageInfo'] start_index = page_info['startIndex'] + allowed_results_per_page - result_count = page_info['resultCount'] - + total_results = page_info.get('totalResults') page_data = page_json.get('data') data.extend(page_data) return data - def __get_page(self, resource, start_at, params=None, **kwargs): + def __get_page(self, resource, start_at, params=None, allowed_results_per_page=__allowed_results_per_page, **kwargs): """This method will return one page of results from the specified resource type. Pass any needed parameters along The response object will be returned""" parameters = { 'startAt': start_at, - 'maxResults': self.__allowed_results_per_page + 'maxResults': allowed_results_per_page } if params is not None: for k, v in params.items(): parameters[k] = v - response = self.__core.get(resource, params=parameters, **kwargs) + try: + response = self.__core.get(resource, params=parameters, **kwargs) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response @@ -2277,51 +3175,31 @@

Inherited members

py_jama_rest_client_logger.error('{} error. {}'.format(status, response.reason)) raise APIException("{} error".format(status), status_code=status, - reason=response.reason)
+ reason=response.reason) + + def set_allowed_results_per_page(self, allowed_results_per_page): + self.__allowed_results_per_page = allowed_results_per_page + + def get_allowed_results_per_page(self): + return self.__allowed_results_per_page

Methods

-
-def __init__(self, host_domain, credentials=('username|clientID', 'password|clientSecret'), api_version='/rest/v1/', oauth=False, verify=True) -
-
-

Jama Client initializer -:rtype: JamaClient -:param host_domain: String The domain associated with the Jama Connect host -:param credentials: the user name and password as a tuple or client id and client secret if using Oauth. -:param api_version: valid args are '/rest/[v1|latest|labs]/' -:param verify: Defaults to True, Setting this to False will skip SSL Certificate verification

-
-Source code -
def __init__(self, host_domain, credentials=('username|clientID', 'password|clientSecret'), api_version='/rest/v1/',
-             oauth=False, verify=True):
-    """Jama Client initializer
-    :rtype: JamaClient
-    :param host_domain: String The domain associated with the Jama Connect host
-    :param credentials: the user name and password as a tuple or client id and client secret if using Oauth.
-    :param api_version: valid args are '/rest/[v1|latest|labs]/'
-    :param verify: Defaults to True, Setting this to False will skip SSL Certificate verification"""
-    self.__credentials = credentials
-    self.__core = Core(host_domain, credentials, api_version=api_version, oauth=oauth, verify=verify)
-
-    # Log client creation
-    py_jama_rest_client_logger.info('Created a new JamaClient instance. Domain: {} '
-                                    'Connecting via Oauth: {}'.format(host_domain, oauth))
-
-
def delete_item(self, item_id)
-

This method will delete an item in Jama Connect.

+

This method will delete an item in Jama Connect.

Args

item_id
The jama connect API ID of the item to be deleted
-

Returns: The success status code.

+

Returns: The success status code.

-Source code + +Expand source code +
def delete_item(self, item_id):
     """
     This method will delete an item in Jama Connect.
@@ -2332,7 +3210,11 @@ 

Args

Returns: The success status code. """ resource_path = 'items/' + str(item_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code
@@ -2341,15 +3223,17 @@

Args

def delete_relationships(self, relationship_id)
-

Deletes a relationship with the specified relationship ID

+

Deletes a relationship with the specified relationship ID

Args

relationship_id
the api project id of a relationship
-

Returns: The success status code.

+

Returns: The success status code.

-Source code + +Expand source code +
def delete_relationships(self, relationship_id):
     """
     Deletes a relationship with the specified relationship ID
@@ -2361,16 +3245,83 @@ 

Args

""" resource_path = 'relationships/' + str(relationship_id) - response = self.__core.delete(resource_path) + try: + response = self.__core.delete(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code
+
+def get_abstract_item(self, item_id) +
+
+

This method will return an item, test plan, test cycle, test run, or attachment with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
+

Returns: a dictonary object representing the abstract item

+
+ +Expand source code + +
def get_abstract_item(self, item_id):
+    """
+    This method will return an item, test plan, test cycle, test run, or attachment with the specified ID
+    Args:
+        item_id: the item id of the item to fetch
+
+    Returns: a dictonary object representing the abstract item
+
+    """
+    resource_path = 'abstractitems/' + str(item_id)
+    try:
+        response = self.__core.get(resource_path)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
+
+def get_abstract_item_versions(self, item_id) +
+
+

Get all versions for the item with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
+

Returns: JSON array with all versions for the item

+
+ +Expand source code + +
def get_abstract_item_versions(self, item_id):
+    """
+    Get all versions for the item with the specified ID
+
+    Args:
+        item_id: the item id of the item to fetch
+
+    Returns: JSON array with all versions for the item
+    """
+    resource_path = 'abstractitems/' + str(item_id) + '/versions'
+    versions = self.__get_all(resource_path)
+    return versions
+
+
def get_abstract_items(self, project=None, item_type=None, document_key=None, release=None, created_date=None, modified_date=None, last_activity_date=None, contains=None, sort_by=None)
-

This method will return all items that match the query parameters entered.

+

This method will return all items that match the query parameters entered.

Args

project
@@ -2414,9 +3365,11 @@

Args

Returns

-

A JSON Array of items.

+

A JSON Array of items.

-Source code + +Expand source code +
def get_abstract_items(self,
                        project=None,
                        item_type=None,
@@ -2482,38 +3435,128 @@ 

Returns

-def get_abstract_items_from_doc_key(self, doc_key_list) +def get_abstract_items_from_doc_key(self, doc_key_list, allowed_results_per_page=20)
-

DEPRECATED INSTEAD USE get_abstract_items below. +

DEPRECATED INSTEAD USE get_abstract_items below. This method will take in a list of document keys and return an array of JSON Objects associated with the -document keys.

+document keys.

-Source code -
def get_abstract_items_from_doc_key(self, doc_key_list):
+
+Expand source code
+
+
def get_abstract_items_from_doc_key(self, doc_key_list, allowed_results_per_page=__allowed_results_per_page):
     """ DEPRECATED INSTEAD USE get_abstract_items below.
     This method will take in a list of document keys and return an array of JSON Objects associated with the
     document keys."""
     resource_path = 'abstractitems'
     params = {'documentKey': doc_key_list}
-    abstract_items = self.__get_all(resource_path, params=params)
+    abstract_items = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page)
     return abstract_items
+
+def get_abstract_versioned_item(self, item_id, version_num) +
+
+

Get the snapshot of the item at the specified version

+

Args

+
+
item_id
+
the item id of the item to fetch
+
version_num
+
the version number for the item
+
+

Returns: a dictionary object representing the versioned item

+
+ +Expand source code + +
def get_abstract_versioned_item(self, item_id, version_num):
+    """
+    Get the snapshot of the item at the specified version
+
+    Args:
+        item_id: the item id of the item to fetch
+        version_num: the version number for the item
+
+    Returns: a dictionary object representing the versioned item
+    """
+    resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem'
+    try:
+        response = self.__core.get(resource_path)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
+
+def get_abtract_item_version(self, item_id, version_num) +
+
+

Get the numbered version for the item with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
version_num
+
the version number for the item
+
+

Returns: a dictionary object representing the numbered version

+
+ +Expand source code + +
def get_abtract_item_version(self, item_id, version_num):
+    """
+    Get the numbered version for the item with the specified ID
+
+    Args:
+        item_id: the item id of the item to fetch
+        version_num: the version number for the item
+
+    Returns: a dictionary object representing the numbered version
+    """
+    resource_path = 'abstractitems/' + str(item_id) + '/versions/' + str(version_num)
+    try:
+        response = self.__core.get(resource_path)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
+
+def get_allowed_results_per_page(self) +
+
+
+
+ +Expand source code + +
def get_allowed_results_per_page(self):
+    return self.__allowed_results_per_page
+
+
def get_attachment(self, attachment_id)
-

This method will return a singular attachment of a specified attachment id

+

This method will return a singular attachment of a specified attachment id

Args

attachment_id
the attachment id of the attachment to fetch
-
Returns : a dictonary object representing the attachment
-
 
-
+ +

Returns: a dictonary object representing the attachment

-Source code + +Expand source code +
def get_attachment(self, attachment_id):
     """
     This method will return a singular attachment of a specified attachment id
@@ -2524,7 +3567,11 @@ 

Args

""" resource_path = 'attachments/' + str(attachment_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
@@ -2533,13 +3580,12 @@

Args

def get_available_endpoints(self)
-

Returns a list of all the available endpoints.

-
-
Returns : an array of available endpoints for this API
-
 
-
+

Returns a list of all the available endpoints.

+

Returns: an array of available endpoints for this API

-Source code + +Expand source code +
def get_available_endpoints(self):
     """
     Returns a list of all the available endpoints.
@@ -2547,7 +3593,11 @@ 

Args

Returns: an array of available endpoints for this API """ - response = self.__core.get('') + try: + response = self.__core.get('') + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
@@ -2556,16 +3606,17 @@

Args

def get_baseline(self, baseline_id)
-

This method will return a baseline

+

This method will return a baseline

Args

baseline_id
the id of the baseline to fetch
-
Returns : a dictionary object representing the baseline
-
 
-
+ +

Returns: a dictionary object representing the baseline

-Source code + +Expand source code +
def get_baseline(self, baseline_id):
     """
     This method will return a baseline
@@ -2576,63 +3627,74 @@ 

Args

""" resource_path = 'baselines/' + str(baseline_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_baselines(self, project_id) +def get_baselines(self, project_id, allowed_results_per_page=20)
-

Returns a list of Baseline objects

+

Returns a list of Baseline objects

Args

project_id
the Id of the project to fetch baselines for
-
Returns : a list of Baseline objects
-
 
-
+
allowed_results_per_page
+
number of results per page
+ +

Returns: a list of Baseline objects

-Source code -
def get_baselines(self, project_id):
+
+Expand source code
+
+
def get_baselines(self, project_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of Baseline objects
     Args:
         project_id:  the Id of the project to fetch baselines for
+        allowed_results_per_page: number of results per page
 
     Returns: a list of Baseline objects
     """
     resource_path = 'baselines'
     params = {'project': project_id}
-    baseline_data = self.__get_all(resource_path, params=params)
+    baseline_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page)
     return baseline_data
-def get_baselines_versioneditems(self, baseline_id) +def get_baselines_versioneditems(self, baseline_id, allowed_results_per_page=20)
-

Get all baseline items in a baseline with the specified ID

+

Get all baseline items in a baseline with the specified ID

Args

baseline_id
The id of the baseline to fetch items for.
-
Returns : A list of versioned items belonging to the baseline
-
 
-
+
allowed_results_per_page
+
Number of results per page
+ +

Returns: A list of versioned items belonging to the baseline

-Source code -
def get_baselines_versioneditems(self, baseline_id):
+
+Expand source code
+
+
def get_baselines_versioneditems(self, baseline_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Get all baseline items in a baseline with the specified ID
     Args:
         baseline_id:  The id of the baseline to fetch items for.
-
+        allowed_results_per_page: Number of results per page
     Returns: A list of versioned items belonging to the baseline
     """
     resource_path = 'baselines/' + str(baseline_id) + '/versioneditems'
-    baseline_items = self.__get_all(resource_path)
+    baseline_items = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return baseline_items
@@ -2640,13 +3702,12 @@

Args

def get_current_user(self)
-

Gets a current user

-
-
Returns : JSON obect
-
 
-
+

Gets a current user

+

Returns: JSON obect

-Source code + +Expand source code +
def get_current_user(self):
     """
     Gets a current user
@@ -2655,33 +3716,42 @@ 

Args

""" resource_path = 'users/current' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data']
-def get_filter_results(self, filter_id, project_id=None) +def get_filter_results(self, filter_id, project_id=None, allowed_results_per_page=20)
-

Get all results items for the filter with the specified ID

+

Get all results items for the filter with the specified ID

Args

filter_id
The ID of the filter to fetch the results for.
project_id
Use this only for filters that run on any project, where projectScope is CURRENT
+
allowed_results_per_page
+
Number of results per page

Returns

-

A List of items that match the filter.

+

A List of items that match the filter.

-Source code -
def get_filter_results(self, filter_id, project_id=None):
+
+Expand source code
+
+
def get_filter_results(self, filter_id, project_id=None, allowed_results_per_page=__allowed_results_per_page):
     """
     Get all results items for the filter with the specified ID
 
     Args:
         filter_id: The ID of the filter to fetch the results for.
         project_id: Use this only for filters that run on any project, where projectScope is CURRENT
+        allowed_results_per_page: Number of results per page
 
     Returns:
         A List of items that match the filter.
@@ -2691,24 +3761,59 @@ 

Returns

params = None if project_id is not None: params = {'project': str(project_id)} - filter_results = self.__get_all(resource_path, params=params) + filter_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return filter_results
+
+def get_filter_results_count(self, filter_id) +
+
+

This method will return count of items found through the specified filter.

+

Args

+
+
filter_id
+
the filter ID
+
+

Returns: a count of the items matched with the filter

+
+ +Expand source code + +
def get_filter_results_count(self, filter_id):
+    """
+    This method will return count of items found through the specified filter.
+    Args:
+        filter_id: the filter ID
+
+    Returns: a count of the items matched with the filter
+
+    """
+    resource_path = 'filters/' + str(filter_id) + '/count'
+    try:
+        response = self.__core.get(resource_path)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
def get_item(self, item_id)
-

This method will return a singular item of a specified item id

+

This method will return a singular item of a specified item id

Args

item_id
the item id of the item to fetch
-
Returns : a dictonary object representing the item
-
 
-
+ +

Returns: a dictonary object representing the item

-Source code + +Expand source code +
def get_item(self, item_id):
     """
     This method will return a singular item of a specified item id
@@ -2719,51 +3824,96 @@ 

Args

""" resource_path = 'items/' + str(item_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_item_children(self, item_id) +def get_item_children(self, item_id, allowed_results_per_page=20)
-

This method will return list of the child items of the item passed to the function.

+

This method will return list of the child items of the item passed to the function.

Args

item_id
(int) The id of the item for which children items should be fetched
+
allowed_results_per_page
+
Number of results per page
-

Returns: a List of Objects that represent the children of the item passed in.

+

Returns: a List of Objects that represent the children of the item passed in.

-Source code -
def get_item_children(self, item_id):
+
+Expand source code
+
+
def get_item_children(self, item_id, allowed_results_per_page=__allowed_results_per_page):
     """
     This method will return list of the child items of the item passed to the function.
     Args:
         item_id: (int) The id of the item for which children items should be fetched
+        allowed_results_per_page: Number of results per page
 
     Returns: a List of Objects that represent the children of the item passed in.
     """
     resource_path = 'items/' + str(item_id) + '/children'
-    child_items = self.__get_all(resource_path)
+    child_items = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return child_items
+ +
+

This method will return all links in the specified item.

+

Args

+
+
item_id
+
the item ID
+
+

Returns: a Json object with the links present in the item specified

+
+ +Expand source code + +
def get_item_links(self, item_id):
+    """
+    This method will return all links in the specified item.
+    Args:
+        item_id: the item ID
+
+    Returns: a Json object with the links present in the item specified
+
+    """
+    resource_path = 'items/' + str(item_id) + '/links'
+    try:
+        response = self.__core.get(resource_path)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
def get_item_lock(self, item_id)
-

Get the locked state, last locked date, and last locked by user for the item with the specified ID

+

Get the locked state, last locked date, and last locked by user for the item with the specified ID

Args

item_id
The API ID of the item to get the lock info for.

Returns

-

A JSON object with the lock information for the item with the specified ID.

+

A JSON object with the lock information for the item with the specified ID.

-Source code + +Expand source code +
def get_item_lock(self, item_id):
     """
     Get the locked state, last locked date, and last locked by user for the item with the specified ID
@@ -2775,25 +3925,63 @@ 

Returns

""" resource_path = 'items/' + str(item_id) + '/lock' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
+
+def get_item_tags(self, item_id, allowed_results_per_page=20) +
+
+

Return all tags for the item with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
allowed_results_per_page
+
number of results
+
+

Returns: a dictionary object representing the item's tags

+
+ +Expand source code + +
def get_item_tags(self, item_id, allowed_results_per_page=__allowed_results_per_page):
+    """
+    Return all tags for the item with the specified ID
+
+    Args:
+        item_id: the item id of the item to fetch
+        allowed_results_per_page: number of results
+
+    Returns: a dictionary object representing the item's tags
+
+    """
+    resource_path = 'items/' + str(item_id) + '/tags'
+    item_tags = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
+    return item_tags
+
+
def get_item_type(self, item_type_id)
-

Gets item type information for a specific item type id.

+

Gets item type information for a specific item type id.

Args

item_type_id
The api id of the item type to fetch
-
Returns : JSON object
-
 
-
+ +

Returns: JSON object

-Source code + +Expand source code +
def get_item_type(self, item_type_id):
     """
     Gets item type information for a specific item type id.
@@ -2805,104 +3993,223 @@ 

Args

""" resource_path = 'itemtypes/' + str(item_type_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_item_types(self) +def get_item_types(self, allowed_results_per_page=20)
-

This method will return all item types of the across all projects of the Jama Connect instance.

+

This method will return all item types of the across all projects of the Jama Connect instance.

+

Args

-
Returns : An array of dictionary objects
-
 
-
+
allowed_results_per_page
+
Number of results per page
+ +

Returns: An array of dictionary objects

-Source code -
def get_item_types(self):
+
+Expand source code
+
+
def get_item_types(self, allowed_results_per_page=__allowed_results_per_page):
     """
     This method will return all item types of the across all projects of the Jama Connect instance.
 
+    Args:
+        allowed_results_per_page: Number of results per page
+
     Returns: An array of dictionary objects
 
     """
     resource_path = 'itemtypes/'
-    item_types = self.__get_all(resource_path)
+    item_types = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return item_types
+
+def get_item_version(self, item_id, version_num) +
+
+

Get the numbered version for the item with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
version_num
+
the version number for the item
+
+

Returns: a dictionary object representing the numbered version

+
+ +Expand source code + +
def get_item_version(self, item_id, version_num):
+    """
+    Get the numbered version for the item with the specified ID
+
+    Args:
+        item_id: the item id of the item to fetch
+        version_num: the version number for the item
+
+    Returns: a dictionary object representing the numbered version
+    """
+    resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num)
+    response = self.__core.get(resource_path)
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
+
+def get_item_versions(self, item_id, allowed_results_per_page=20) +
+
+

Get all versions for the item with the specified ID

+

Args

+
+
item_id
+
the item id of the item to fetch
+
allowed_results_per_page
+
number of results per page
+
+

Returns: JSON array with all versions for the item

+
+ +Expand source code + +
def get_item_versions(self, item_id, allowed_results_per_page=__allowed_results_per_page):
+    """
+    Get all versions for the item with the specified ID
+
+    Args:
+        item_id: the item id of the item to fetch
+        allowed_results_per_page: number of results per page
+
+    Returns: JSON array with all versions for the item
+    """
+    resource_path = 'items/' + str(item_id) + '/versions'
+    versions = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
+    return versions
+
+
+
+def get_item_workflow_transitions(self, item_id) +
+
+

Get all valid workflow transitions that can be made with the specified id

+

Args

+
+
item_id
+
the api id of the item
+
allowed_results_per_page
+
number of results per page
+
+

Returns: an array of dictionary objects that represent the workflow transitions for the item.

+
+ +Expand source code + +
def get_item_workflow_transitions(self, item_id):
+    """
+    Get all valid workflow transitions that can be made with the specified id
+
+    Args:
+        item_id: the api id of the item
+        allowed_results_per_page: number of results per page
+
+    Returns: an array of dictionary objects that represent the workflow transitions for the item.
+
+    """
+    resource_path = 'items/' + str(item_id) + '/workflowtransitionoptions'
+    return self.__get_all(resource_path)
+
+
-def get_items(self, project_id) +def get_items(self, project_id, allowed_results_per_page=20)
-

This method will return all items in the specified project.

+

This method will return all items in the specified project.

Args

project_id
the project ID
-
Returns : a Json array of item objects
-
 
-
+
allowed_results_per_page
+
number of results per page
+ +

Returns: a Json array of item objects

-Source code -
def get_items(self, project_id):
+
+Expand source code
+
+
def get_items(self, project_id, allowed_results_per_page=__allowed_results_per_page):
     """
     This method will return all items in the specified project.
     Args:
         project_id: the project ID
+        allowed_results_per_page: number of results per page
 
     Returns: a Json array of item objects
 
     """
     resource_path = 'items'
     params = {'project': project_id}
-    item_data = self.__get_all(resource_path, params=params)
+    item_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page)
     return item_data
-

Returns a list of all the downstream related items for the item with the specified ID.

+

Returns a list of all the downstream related items for the item with the specified ID.

Args

item_id
the api id of the item to fetch downstream items for
+
allowed_results_per_page
+
number of results per page
-

Returns: an array of dictionary objects that represent the downstream related items for the specified item.

+

Returns: an array of dictionary objects that represent the downstream related items for the specified item.

-Source code -
def get_items_downstream_related(self, item_id):
+
+Expand source code
+
+
def get_items_downstream_related(self, item_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of all the downstream related items for the item with the specified ID.
 
     Args:
         item_id: the api id of the item to fetch downstream items for
+        allowed_results_per_page: number of results per page
 
     Returns: an array of dictionary objects that represent the downstream related items for the specified item.
 
     """
     resource_path = 'items/' + str(item_id) + '/downstreamrelated'
-    return self.__get_all(resource_path)
+ return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page)
-def get_items_downstream_relationships(self, item_id) +def get_items_downstream_relationships(self, item_id, allowed_results_per_page=20)
-

Returns a list of all the downstream relationships for the item with the specified ID.

+

Returns a list of all the downstream relationships for the item with the specified ID.

Args

item_id
the api id of the item
-

Returns: an array of dictionary objects that represent the downstream relationships for the item.

+

Returns: an array of dictionary objects that represent the downstream relationships for the item.

-Source code -
def get_items_downstream_relationships(self, item_id):
+
+Expand source code
+
+
def get_items_downstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of all the downstream relationships for the item with the specified ID.
 
@@ -2913,37 +4220,41 @@ 

Args

""" resource_path = 'items/' + str(item_id) + '/downstreamrelationships' - return self.__get_all(resource_path)
+ return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page)
-def get_items_synceditems(self, item_id) +def get_items_synceditems(self, item_id, allowed_results_per_page=20)
-

Get all synchronized items for the item with the specified ID

+

Get all synchronized items for the item with the specified ID

Args

item_id
The API id of the item being
-
Returns : A list of JSON Objects representing the items that are in the same synchronization group as the
-
 
+
allowed_results_per_page
+
Number of results per page
-

specified item.

+

Returns: A list of JSON Objects representing the items that are in the same synchronization group as the +specified item.

-Source code -
def get_items_synceditems(self, item_id):
+
+Expand source code
+
+
def get_items_synceditems(self, item_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Get all synchronized items for the item with the specified ID
 
     Args:
         item_id: The API id of the item being
+        allowed_results_per_page: Number of results per page
 
     Returns: A list of JSON Objects representing the items that are in the same synchronization group as the
     specified item.
 
     """
     resource_path = 'items/' + str(item_id) + '/synceditems'
-    synced_items = self.__get_all(resource_path)
+    synced_items = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return synced_items
@@ -2951,7 +4262,7 @@

Args

def get_items_synceditems_status(self, item_id, synced_item_id)
-

Get the sync status for the synced item with the specified ID

+

Get the sync status for the synced item with the specified ID

Args

item_id
@@ -2959,9 +4270,11 @@

Args

synced_item_id
the id of the item to check if it is in sync
-

Returns: The response JSON from the API which contains a single field 'inSync' with a boolean value.

+

Returns: The response JSON from the API which contains a single field 'inSync' with a boolean value.

-Source code + +Expand source code +
def get_items_synceditems_status(self, item_id, synced_item_id):
     """
     Get the sync status for the synced item with the specified ID
@@ -2974,50 +4287,90 @@ 

Args

""" resource_path = 'items/' + str(item_id) + '/synceditems/' + str(synced_item_id) + '/syncstatus' - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
+ +
+

Returns a list of all the upstream related items for the item with the specified ID.

+

Args

+
+
item_id
+
the api id of the item to fetch upstream items for
+
+

Returns: an array of dictionary objects that represent the upstream related items for the specified item.

+
+ +Expand source code + +
def get_items_upstream_related(self, item_id):
+    """
+    Returns a list of all the upstream related items for the item with the specified ID.
+
+    Args:
+        item_id: the api id of the item to fetch upstream items for
+
+    Returns: an array of dictionary objects that represent the upstream related items for the specified item.
+
+     """
+    resource_path = 'items/' + str(item_id) + '/upstreamrelated'
+    return self.__get_all(resource_path)
+
+
-def get_items_upstream_relationships(self, item_id) +def get_items_upstream_relationships(self, item_id, allowed_results_per_page=20)
-

Returns a list of all the upstream relationships for the item with the specified ID.

+

Returns a list of all the upstream relationships for the item with the specified ID.

Args

item_id
the api id of the item
+
allowed_results_per_page
+
number of results per page
-

Returns: an array of dictionary objects that represent the upstream relationships for the item.

+

Returns: an array of dictionary objects that represent the upstream relationships for the item.

-Source code -
def get_items_upstream_relationships(self, item_id):
+
+Expand source code
+
+
def get_items_upstream_relationships(self, item_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of all the upstream relationships for the item with the specified ID.
     Args:
         item_id: the api id of the item
+        allowed_results_per_page: number of results per page
 
     Returns: an array of dictionary objects that represent the upstream relationships for the item.
 
     """
     resource_path = 'items/' + str(item_id) + '/upstreamrelationships'
-    return self.__get_all(resource_path)
+ return self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page)
def get_pick_list(self, pick_list_id)
-

Gets all a singular picklist

+

Gets all a singular picklist

Args

pick_list_id
The API id of the pick list to fetch
-

Returns: a dictionary object representing the picklist.

+

Returns: a dictionary object representing the picklist.

-Source code + +Expand source code +
def get_pick_list(self, pick_list_id):
     """
     Gets all a singular picklist
@@ -3029,7 +4382,11 @@ 

Args

""" resource_path = 'picklists/' + str(pick_list_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
@@ -3038,15 +4395,17 @@

Args

def get_pick_list_option(self, pick_list_option_id)
-

Fetches a single picklist option from the API

+

Fetches a single picklist option from the API

Args

pick_list_option_id
The API ID of the picklist option to fetch
-

Returns: A dictonary object representing the picklist option.

+

Returns: A dictonary object representing the picklist option.

-Source code + +Expand source code +
def get_pick_list_option(self, pick_list_option_id):
     """
     Fetches a single picklist option from the API
@@ -3057,75 +4416,93 @@ 

Args

""" resource_path = 'picklistoptions/' + str(pick_list_option_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_pick_list_options(self, pick_list_id) +def get_pick_list_options(self, pick_list_id, allowed_results_per_page=20)
-

Gets all all the picklist options for a single picklist

+

Gets all all the picklist options for a single picklist

Args

pick_list_id
the api id of the picklist to fetch options for.
+
allowed_results_per_page
+
number of results per page
-

Returns: an array of dictionary objects that represent the picklist options.

+

Returns: an array of dictionary objects that represent the picklist options.

-Source code -
def get_pick_list_options(self, pick_list_id):
+
+Expand source code
+
+
def get_pick_list_options(self, pick_list_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Gets all all the picklist options for a single picklist
     Args:
         pick_list_id: the api id of the picklist to fetch options for.
+        allowed_results_per_page: number of results per page
 
     Returns: an array of dictionary objects that represent the picklist options.
 
     """
     resource_path = 'picklists/' + str(pick_list_id) + '/options'
-    pick_list_options = self.__get_all(resource_path)
+    pick_list_options = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return pick_list_options
-def get_pick_lists(self) +def get_pick_lists(self, allowed_results_per_page=20)
-

Returns a list of all the pick lists

+

Returns a list of all the pick lists

+

Args

-
Returns : an array of dictionary objects
-
 
-
+
allowed_results_per_page
+
number of results per page
+ +

Returns: an array of dictionary objects

-Source code -
def get_pick_lists(self):
+
+Expand source code
+
+
def get_pick_lists(self, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of all the pick lists
 
+    Args:
+        allowed_results_per_page: number of results per page
+
     Returns: an array of dictionary objects
 
     """
     resource_path = 'picklists/'
-    pick_lists = self.__get_all(resource_path)
+    pick_lists = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return pick_lists
-def get_projects(self) +def get_projects(self, allowed_results_per_page=20)
-

This method will return all projects as JSON object -:return: JSON Array of Item Objects.

+

This method will return all projects as JSON object +:return: JSON Array of Item Objects.

-Source code -
def get_projects(self):
+
+Expand source code
+
+
def get_projects(self, allowed_results_per_page=__allowed_results_per_page):
     """This method will return all projects as JSON object
     :return: JSON Array of Item Objects.
     """
     resource_path = 'projects'
-    project_data = self.__get_all(resource_path)
+    project_data = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return project_data
@@ -3133,16 +4510,17 @@

Args

def get_relationship(self, relationship_id)
-

Returns a specific relationship object of a specified relationship ID

+

Returns a specific relationship object of a specified relationship ID

Args

relationship_id
the api project id of a relationship
-
Returns : a dictionary object that represents a relationship
-
 
-
+ +

Returns: a dictionary object that represents a relationship

-Source code + +Expand source code +
def get_relationship(self, relationship_id):
     """
     Returns a specific relationship object of a specified relationship ID
@@ -3154,25 +4532,97 @@ 

Args

""" resource_path = 'relationships/' + str(relationship_id) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data']
+
+
+
+def get_relationship_rule_set(self, id) +
+
+

This method will return the relationship rule sets by id.

+

Returns: A dictionary object representing a rule set and its associated rules

+
+ +Expand source code + +
def get_relationship_rule_set(self, id):
+    """
+    This method will return the relationship rule sets by id.
+
+    Returns: A dictionary object representing a rule set and its associated rules
+
+    """
+    resource_path = 'relationshiprulesets/' + str(id)
     response = self.__core.get(resource_path)
     JamaClient.__handle_response_status(response)
     return response.json()['data']
+
+def get_relationship_rule_set_projects(self, id) +
+
+

This method will return the projects that have a given relationship rule set defined.

+

Returns: An array of the dictionary objects representing the projects with a given rule set assigned

+
+ +Expand source code + +
def get_relationship_rule_set_projects(self, id):
+    """
+    This method will return the projects that have a given relationship rule set defined.
+
+    Returns: An array of the dictionary objects representing the projects with a given rule set assigned
+
+    """
+    resource_path = 'relationshiprulesets/' + str(id) + '/projects'
+    projects = self.__get_all(resource_path)
+    return projects
+
+
+
+def get_relationship_rule_sets(self) +
+
+

This method will return all relationship rule sets across all projects of the Jama Connect instance.

+

Returns: An array of dictionary objects representing a rule set and its associated rules

+
+ +Expand source code + +
def get_relationship_rule_sets(self):
+    """
+    This method will return all relationship rule sets across all projects of the Jama Connect instance.
+
+    Returns: An array of dictionary objects representing a rule set and its associated rules
+
+    """
+    resource_path = 'relationshiprulesets/'
+    rule_sets = self.__get_all(resource_path)
+    return rule_sets
+
+
def get_relationship_type(self, relationship_type_id)
-

Gets relationship type information for a specific relationship type id.

+

Gets relationship type information for a specific relationship type id.

Args

relationship_type_id
The api id of the item type to fetch
-
Returns : JSON object
-
 
-
+ +

Returns: JSON object

-Source code + +Expand source code +
def get_relationship_type(self, relationship_type_id):
     """
     Gets relationship type information for a specific relationship type id.
@@ -3184,84 +4634,105 @@ 

Args

""" resource_path = 'relationshiptypes/' + str(relationship_type_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_relationship_types(self) +def get_relationship_types(self, allowed_results_per_page=20)
-

This method will return all relationship types of the across all projects of the Jama Connect instance.

+

This method will return all relationship types of the across all projects of the Jama Connect instance.

+

Args

-
Returns : An array of dictionary objects
-
 
-
+
allowed_results_per_page
+
Number of results per page
+ +

Returns: An array of dictionary objects

-Source code -
def get_relationship_types(self):
+
+Expand source code
+
+
def get_relationship_types(self, allowed_results_per_page=__allowed_results_per_page):
     """
     This method will return all relationship types of the across all projects of the Jama Connect instance.
 
+    Args:
+        allowed_results_per_page: Number of results per page
+
     Returns: An array of dictionary objects
 
     """
     resource_path = 'relationshiptypes/'
-    item_types = self.__get_all(resource_path)
+    item_types = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return item_types
-def get_relationships(self, project_id) +def get_relationships(self, project_id, allowed_results_per_page=20)
-

Returns a list of all relationships of a specified project

+

Returns a list of all relationships of a specified project

Args

project_id
the api project id of a project
-
Returns : a list of dictionary objects that represents a relationships
-
 
-
+
allowed_results_per_page
+
number of results per page
+ +

Returns: a list of dictionary objects that represents a relationships

-Source code -
def get_relationships(self, project_id):
+
+Expand source code
+
+
def get_relationships(self, project_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Returns a list of all relationships of a specified project
 
     Args:
         project_id: the api project id of a project
+        allowed_results_per_page: number of results per page
 
     Returns: a list of dictionary objects that represents a relationships
 
     """
     resource_path = 'relationships'
     params = {'project': project_id}
-    relationship_data = self.__get_all(resource_path, params=params)
+    relationship_data = self.__get_all(resource_path, params=params,
+                                       allowed_results_per_page=allowed_results_per_page)
     return relationship_data
-def get_tagged_items(self, tag_id) +def get_tagged_items(self, tag_id, allowed_results_per_page=20)
-

Get all items tagged with the specified ID

+

Get all items tagged with the specified ID

Args

tag_id
The ID of the tag to fetch the results for.
+
allowed_results_per_page
+
Number of results per page

Returns

-

A List of items that match the tag.

+

A List of items that match the tag.

-Source code -
def get_tagged_items(self, tag_id):
+
+Expand source code
+
+
def get_tagged_items(self, tag_id, allowed_results_per_page=__allowed_results_per_page):
     """
     Get all items tagged with the specified ID
 
     Args:
         tag_id: The ID of the tag to fetch the results for.
+        allowed_results_per_page: Number of results per page
 
     Returns:
         A List of items that match the tag.
@@ -3269,35 +4740,40 @@ 

Returns

""" resource_path = 'tags/' + str(tag_id) + '/items' params = None - tag_results = self.__get_all(resource_path, params=params) + tag_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_results
-def get_tags(self, project) +def get_tags(self, project, allowed_results_per_page=20)
-

Get all tags for the project with the specified id

+

Get all tags for the project with the specified id

Args

project
The API ID of the project to fetch tags for.
+
allowed_results_per_page
+
Number of results per page
-

Returns: A Json Array that contains all the tag data for the specified project.

+

Returns: A Json Array that contains all the tag data for the specified project.

-Source code -
def get_tags(self, project):
+
+Expand source code
+
+
def get_tags(self, project, allowed_results_per_page=__allowed_results_per_page):
     """
     Get all tags for the project with the specified id
     Args:
         project: The API ID of the project to fetch tags for.
+        allowed_results_per_page: Number of results per page
 
     Returns: A Json Array that contains all the tag data for the specified project.
 
     """
     resource_path = 'tags'
     params = {'project': project}
-    tag_data = self.__get_all(resource_path, params=params)
+    tag_data = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page)
     return tag_data
@@ -3305,16 +4781,17 @@

Args

def get_test_cycle(self, test_cycle_id)
-

This method will return JSON data about the test cycle specified by the test cycle id.

+

This method will return JSON data about the test cycle specified by the test cycle id.

Args

test_cycle_id
the api id of the test cycle to fetch
-
Returns : a dictionary object that represents the test cycle
-
 
-
+ +

Returns: a dictionary object that represents the test cycle

-Source code + +Expand source code +
def get_test_cycle(self, test_cycle_id):
     """
     This method will return JSON data about the test cycle specified by the test cycle id.
@@ -3326,25 +4803,31 @@ 

Args

""" resource_path = 'testcycles/' + str(test_cycle_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['data']
-def get_testruns(self, test_cycle_id) +def get_testruns(self, test_cycle_id, allowed_results_per_page=20)
-

This method will return all test runs associated with the specified test cycle. +

This method will return all test runs associated with the specified test cycle. Test runs will be returned -as a list of json objects.

+as a list of json objects.

-Source code -
def get_testruns(self, test_cycle_id):
+
+Expand source code
+
+
def get_testruns(self, test_cycle_id, allowed_results_per_page=__allowed_results_per_page):
     """This method will return all test runs associated with the specified test cycle.  Test runs will be returned
     as a list of json objects."""
     resource_path = 'testcycles/' + str(test_cycle_id) + '/testruns'
-    testrun_data = self.__get_all(resource_path)
+    testrun_data = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return testrun_data
@@ -3352,16 +4835,17 @@

Args

def get_user(self, user_id)
-

Gets a single speificed user

+

Gets a single speificed user

Args

user_id
user api ID
-
Returns : JSON obect
-
 
-
+ +

Returns: JSON obect

-Source code + +Expand source code +
def get_user(self, user_id):
     """
     Gets a single speificed user
@@ -3373,56 +4857,101 @@ 

Args

""" resource_path = 'users/' + str(user_id) - response = self.__core.get(resource_path) + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return response.json()['data']
-def get_users(self) +def get_users(self, allowed_results_per_page=20)
-

Gets a list of all active users visible to the current user

+

Gets a list of all active users visible to the current user

+

Args

-
Returns : JSON array
-
 
-
+
allowed_results_per_page
+
Number of results per page
+ +

Returns: JSON array

-Source code -
def get_users(self):
+
+Expand source code
+
+
def get_users(self, allowed_results_per_page=__allowed_results_per_page):
     """
     Gets a list of all active users visible to the current user
 
+    Args:
+        allowed_results_per_page: Number of results per page
+
     Returns: JSON array
 
     """
     resource_path = 'users/'
-    users = self.__get_all(resource_path)
+    users = self.__get_all(resource_path,  allowed_results_per_page=allowed_results_per_page)
     return users
+
+def get_versioned_item(self, item_id, version_num) +
+
+

Get the snapshot of the item at the specified version

+

Args

+
+
item_id
+
the item id of the item to fetch
+
version_num
+
the version number for the item
+
+

Returns: a dictionary object representing the versioned item

+
+ +Expand source code + +
def get_versioned_item(self, item_id, version_num):
+    """
+    Get the snapshot of the item at the specified version
+
+    Args:
+        item_id: the item id of the item to fetch
+        version_num: the version number for the item
+
+    Returns: a dictionary object representing the versioned item
+    """
+    resource_path = 'items/' + str(item_id) + '/versions/' + str(version_num) + '/versioneditem'
+    response = self.__core.get(resource_path)
+    JamaClient.__handle_response_status(response)
+    return response.json()['data']
+
+
def patch_item(self, item_id, patches)
-

This method will patch an item.

+

This method will patch an item.

Args

item_id
the API ID of the item that is to be patched
patches
An array of dicts, that represent patch operations each dict should have the following entries
-
[
-
{
-
"op": string,
-
"path": string,
-
"value":
-
}
-
]
-
Returns : The response status code
-
 
-
+ +

[ +{ +"op": string, +"path": string, +"value": {} +} +] +Returns: The response status code

-Source code + +Expand source code +
def patch_item(self, item_id, patches):
     """
     This method will patch an item.
@@ -3447,7 +4976,11 @@ 

Args

data = json.dumps(patches) # Make the API Call - response = self.__core.patch(resource_path, data=data, headers=headers) + try: + response = self.__core.patch(resource_path, data=data, headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # validate response JamaClient.__handle_response_status(response) @@ -3458,16 +4991,18 @@

Args

def post_item(self, project, item_type_id, child_item_type_id, location, fields, global_id=None)
-

This method will post a new item to Jama Connect. +

This method will post a new item to Jama Connect. :param global_id: optional param to post the item with a custom global id :param project integer representing the project to which this item is to be posted :param item_type_id integer ID of an Item Type. :param child_item_type_id integer ID of an Item Type. :param location dictionary with integer ID of the parent item or project. :param fields dictionary item field data. -:return integer ID of the successfully posted item or None if there was an error.

+:return integer ID of the successfully posted item or None if there was an error.

-Source code + +Expand source code +
def post_item(self, project, item_type_id, child_item_type_id, location, fields, global_id=None):
     """ This method will post a new item to Jama Connect.
     :param global_id: optional param to post the item with a custom global id
@@ -3496,7 +5031,11 @@ 

Args

params['setGlobalIdManually'] = True headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers, params=params) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
@@ -3505,12 +5044,14 @@

Args

def post_item_attachment(self, item_id, attachment_id)
-

Add an existing attachment to the item with the specified ID +

Add an existing attachment to the item with the specified ID :param item_id: this is the ID of the item :param attachment_id: The ID of the attachment -:return: 201 if successful / the response status of the post operation

+:return: 201 if successful / the response status of the post operation

-Source code + +Expand source code +
def post_item_attachment(self, item_id, attachment_id):
     """
     Add an existing attachment to the item with the specified ID
@@ -3521,16 +5062,20 @@ 

Args

body = {"attachment": attachment_id} resource_path = 'items/' + str(item_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code
-def post_item_sync(self, source_item, pool_item) +def post_item_sync(self, source_item: int, pool_item: int)
-

add an item to an existing pool of global ids

+

add an item to an existing pool of global ids

Args

source_item
@@ -3539,9 +5084,11 @@

Args

pool_item
integer API ID of the item in the target global ID pool.
-

Returns: the integer ID of the modified source item.

+

Returns: the integer ID of the modified source item.

-Source code + +Expand source code +
def post_item_sync(self, source_item: int, pool_item: int):
     """
     add an item to an existing pool of global ids
@@ -3558,7 +5105,11 @@ 

Args

resource_path = 'items/' + str(pool_item) + '/synceditems' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
@@ -3567,18 +5118,19 @@

Args

def post_item_tag(self, item_id, tag_id)
-

Add an existing tag to the item with the specified ID

+

Add an existing tag to the item with the specified ID

Args

item_id
The API ID of the item to add a tag.
tag_id
The API ID of the tag to add to the item.
-
Returns : 201 if successful
-
 
-
+ +

Returns: 201 if successful

-Source code + +Expand source code +
def post_item_tag(self, item_id, tag_id):
     """
     Add an existing tag to the item with the specified ID
@@ -3594,7 +5146,11 @@ 

Args

} resource_path = 'items/' + str(item_id) + '/tags' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.status_code
@@ -3603,14 +5159,16 @@

Args

def post_project_attachment(self, project_id, name, description)
-

This Method will make a new attachment object in the specified project +

This Method will make a new attachment object in the specified project :param project_id: The integer project ID to create the attachment in. :param name: The name of the attachment :param description: The description of the attachment -:return: Returns the ID of the newly created attachment object.

+:return: Returns the ID of the newly created attachment object.

-Source code + +Expand source code +
def post_project_attachment(self, project_id, name, description):
     """
     This Method will make a new attachment object in the specified project
@@ -3628,16 +5186,20 @@ 

Args

resource_path = 'projects/' + str(project_id) + '/attachments' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
-def post_relationship(self, from_item, to_item, relationship_type=None) +def post_relationship(self, from_item: int, to_item: int, relationship_type=None)
-

Args

+

Args

from_item
integer API id of the source item
@@ -3646,9 +5208,11 @@

Args

relationship_type
Optional integer API id of the relationship type to create
-

Returns: The integer ID of the newly created relationship.

+

Returns: The integer ID of the newly created relationship.

-Source code + +Expand source code +
def post_relationship(self, from_item: int, to_item: int, relationship_type=None):
     """
 
@@ -3668,16 +5232,20 @@ 

Args

body['relationshipType'] = relationship_type resource_path = 'relationships/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
-def post_tag(self, name, project) +def post_tag(self, name: str, project: int)
-

Create a new tag in the project with the specified ID

+

Create a new tag in the project with the specified ID

Args

name
@@ -3685,9 +5253,11 @@

Args

project
The project to create the new tag in
-

Returns: The integer API ID fr the newly created Tag.

+

Returns: The integer API ID fr the newly created Tag.

-Source code + +Expand source code +
def post_tag(self, name: str, project: int):
     """
     Create a new tag in the project with the specified ID
@@ -3703,7 +5273,11 @@ 

Args

'project': project } headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
@@ -3712,7 +5286,7 @@

Args

def post_testplans_testcycles(self, testplan_id, testcycle_name, start_date, end_date, testgroups_to_include=None, testrun_status_to_include=None)
-

This method will create a new Test Cycle.

+

This method will create a new Test Cycle.

Args

testplan_id : int
@@ -3723,17 +5297,19 @@

Args

Start date in 'yyyy-mm-dd' Format
end_date : str
End date in 'yyyy-mm-dd' Format
-
testgroups_to_include : int[]
+
testgroups_to_include : int[]
This array of integers specify the test groups to be included.
-
testrun_status_to_include : str[]
+
testrun_status_to_include : str[]
Only valid after generating the first Test Cycle, you may choose to only generate Test Runs that were a specified status in the previous cycle. Do not specify anything to include all statuses

Returns

-

(int): Returns the integer id for the newly created testcycle, or None if something went terribly wrong.

+

(int): Returns the integer id for the newly created testcycle, or None if something went terribly wrong.

-Source code + +Expand source code +
def post_testplans_testcycles(self, testplan_id, testcycle_name, start_date, end_date, testgroups_to_include=None,
                               testrun_status_to_include=None):
     """
@@ -3770,7 +5346,11 @@ 

Returns

} # Make the API Call - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) # Validate response JamaClient.__handle_response_status(response) @@ -3781,7 +5361,7 @@

Returns

def post_user(self, username, password, first_name, last_name, email, license_type, phone=None, title=None, location=None)
-

Creates a new user

+

Creates a new user

Args

username
@@ -3802,11 +5382,12 @@

Args

str - optional
licenseType
enum [ NAMED, FLOATING, STAKEHOLDER, FLOATING_COLLABORATOR, RESERVED_COLLABORATOR, FLOATING_REVIEWER, RESERVED_REVIEWER, NAMED_REVIEWER, TEST_RUNNER, EXPIRING_TRIAL, INACTIVE ]
-
Returns : int of newly created user api ID
-
 
-
+ +

Returns: int of newly created user api ID

-Source code + +Expand source code +
def post_user(self, username, password, first_name, last_name, email, license_type, phone=None, title=None,
               location=None):
     """
@@ -3840,7 +5421,11 @@ 

Args

} resource_path = 'users/' headers = {'content-type': 'application/json'} - response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) JamaClient.__handle_response_status(response) return response.json()['meta']['id']
@@ -3849,12 +5434,14 @@

Args

def put_attachments_file(self, attachment_id, file_path)
-

Upload a file to a jama attachment +

Upload a file to a jama attachment :param attachment_id: the integer ID of the attachment item to which we are uploading the file :param file_path: the file path of the file to be uploaded -:return: returns the status code of the call

+:return: returns the status code of the call

-Source code + +Expand source code +
def put_attachments_file(self, attachment_id, file_path):
     """
     Upload a file to a jama attachment
@@ -3865,8 +5452,11 @@ 

Args

resource_path = 'attachments/' + str(attachment_id) + '/file' with open(file_path, 'rb') as f: files = {'file': f} - response = self.__core.put(resource_path, files=files) - + try: + response = self.__core.put(resource_path, files=files) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) self.__handle_response_status(response) return response.status_code
@@ -3875,7 +5465,7 @@

Args

def put_item(self, project, item_id, item_type_id, child_item_type_id, location, fields)
-

This method wil +

This method wil PUT a new item to Jama Connect. :param project integer representing the project to which this item is to be posted :param item_id integer representing the item which is to be updated @@ -3884,9 +5474,11 @@

Args

:param location dictionary with a key of 'item' or 'project' and an value with the ID of the parent :param fields dictionary item field data. -:return integer ID of the successfully posted item or None if there was an error.

+:return integer ID of the successfully posted item or None if there was an error.

-Source code + +Expand source code +
def put_item(self, project, item_id, item_type_id, child_item_type_id, location, fields):
     """ This method wil
      PUT a new item to Jama Connect.
@@ -3909,7 +5501,11 @@ 

Args

} resource_path = 'items/' + str(item_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response)
@@ -3917,7 +5513,7 @@

Args

def put_item_lock(self, item_id, locked)
-

Update the locked state of the item with the specified ID

+

Update the locked state of the item with the specified ID

Args

item_id
@@ -3926,9 +5522,11 @@

Args

boolean lock state to apply to this item

Returns

-

response status 200

+

response status 200

-Source code + +Expand source code +
def put_item_lock(self, item_id, locked):
     """
     Update the locked state of the item with the specified ID
@@ -3945,7 +5543,11 @@ 

Returns

} resource_path = 'items/' + str(item_id) + '/lock' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response)
@@ -3953,14 +5555,20 @@

Returns

def put_test_run(self, test_run_id, data=None)
-

This method will post a test run to Jama through the API

+

This method will post a test run to Jama through the API

-Source code + +Expand source code +
def put_test_run(self, test_run_id, data=None):
     """ This method will post a test run to Jama through the API"""
     resource_path = 'testruns/' + str(test_run_id)
     headers = {'content-type': 'application/json'}
-    response = self.__core.put(resource_path, data=data, headers=headers)
+    try:
+        response = self.__core.put(resource_path, data=data, headers=headers)
+    except CoreException as err:
+        py_jama_rest_client_logger.error(err)
+        raise APIException(str(err))
     return self.__handle_response_status(response)
@@ -3968,7 +5576,7 @@

Returns

def put_user(self, user_id, username, password, first_name, last_name, email, phone=None, title=None, location=None)
-

updates an existing user

+

updates an existing user

Args

username
@@ -3987,11 +5595,12 @@

Args

str - optional
location
str - optional
-
Returns : api status code
-
 
-
+ +

Returns: api status code

-Source code + +Expand source code +
def put_user(self, user_id, username, password, first_name, last_name, email, phone=None, title=None,
              location=None):
     """
@@ -4023,7 +5632,12 @@ 

Args

} resource_path = 'users/' + str(user_id) headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + raise APIException return self.__handle_response_status(response)
@@ -4031,16 +5645,17 @@

Args

def put_user_active(self, user_id, is_active)
-

updates an existing users active status

+

updates an existing users active status

Args

is_active
boolean
-
Returns : api status code
-
 
-
+ +

Returns: api status code

-Source code + +Expand source code +
def put_user_active(self, user_id, is_active):
     """
     updates an existing users active status
@@ -4056,73 +5671,90 @@ 

Args

} resource_path = 'users/' + str(user_id) + '/active' headers = {'content-type': 'application/json'} - response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + try: + response = self.__core.put(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) return self.__handle_response_status(response)
+
+def set_allowed_results_per_page(self, allowed_results_per_page) +
+
+
+
+ +Expand source code + +
def set_allowed_results_per_page(self, allowed_results_per_page):
+    self.__allowed_results_per_page = allowed_results_per_page
+
+
class ResourceNotFoundException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is raised whenever the api returns a 404 not found response.

+

This exception is raised whenever the api returns a 404 not found response.

-Source code + +Expand source code +
class ResourceNotFoundException(APIException):
     """This exception is raised whenever the api returns a 404 not found response."""
     pass
-

Inherited members

-
class TooManyRequestsException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is thrown whenever the api returns a 429 too many requests response.

+

This exception is thrown whenever the api returns a 429 too many requests response.

-Source code + +Expand source code +
class TooManyRequestsException(APIException):
     """This exception is thrown whenever the api returns a 429 too many requests response."""
     pass
-

Inherited members

+

Ancestors

class UnauthorizedException -(ancestors: APIException, builtins.Exception, builtins.BaseException) +(message, status_code=None, reason=None)
-

This exception is thrown whenever the api returns a 401 unauthorized response.

+

This exception is thrown whenever the api returns a 401 unauthorized response.

-Source code + +Expand source code +
class UnauthorizedException(APIException):
     """This exception is thrown whenever the api returns a 401 unauthorized response."""
     pass
-

Inherited members

-
@@ -4146,9 +5778,6 @@

APIException

-
  • APIServerException

    @@ -4159,11 +5788,15 @@

    JamaClient

  • @@ -4230,9 +5875,7 @@

    -

    Generated by pdoc 0.5.3.

    +

    Generated by pdoc 0.10.0.

    - - \ No newline at end of file diff --git a/docs/py_jama_rest_client/core.html b/docs/py_jama_rest_client/core.html index a61a13b..b5de7aa 100644 --- a/docs/py_jama_rest_client/core.html +++ b/docs/py_jama_rest_client/core.html @@ -3,25 +3,29 @@ - + py_jama_rest_client.core API documentation - - - - - + + + + + + +
    -

    py_jama_rest_client.core module

    +

    Module py_jama_rest_client.core

    -Source code + +Expand source code +
    import math
     
     import requests
    @@ -33,6 +37,20 @@ 

    py_jama_rest_client.core module

    py_jama_rest_client_logger = logging.getLogger('py_jama_rest_client-core') +class CoreException(Exception): + """This is the base class for all exceptions raised by the Core""" + + def __init__(self, message, status_code=None, reason=None): + super(CoreException, self).__init__(message) + self.status_code = status_code + self.reason = reason + + +class UnauthorizedTokenException(CoreException): + """This exception is thrown whenever fetching the oauth token returns a 401 unauthorized response.""" + pass + + class Core: """ This Class will contain a collection of methods that interact directly with the Jama API and return A Requests Response Object. This class will give the user more fine grained access to the JAMA API. For more information @@ -134,8 +152,13 @@

    py_jama_rest_client.core module

    # By getting the system time before we get the token we avoid a potential bug where the token may be expired. time_before_request = time.time() - # Post to the token server - response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify) + # Post to the token server, check if authorized + try: + response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify) + response.raise_for_status() + except requests.exceptions.HTTPError as err: + message = "Unable to fetch token: " + raise UnauthorizedTokenException(message + str(err), response.status_code) # If success get relevant data if response.status_code in [200, 201]: @@ -166,15 +189,18 @@

    Classes

    class Core +(host_name, user_credentials, api_version='/rest/v1/', oauth=False, verify=True)
    -

    This Class will contain a collection of methods that interact directly with the Jama API and return A Requests +

    This Class will contain a collection of methods that interact directly with the Jama API and return A Requests Response Object. This class will give the user more fine grained access to the JAMA API. For more information -on the Requests library visit: http://docs.python-requests.org/en/master/

    +on the Requests library visit: http://docs.python-requests.org/en/master/

    -Source code + +Expand source code +
    class Core:
         """ This Class will contain a collection of methods that interact directly with the Jama API and return A Requests
         Response Object.  This class will give the user more fine grained access to the JAMA API.  For more information
    @@ -276,8 +302,13 @@ 

    Classes

    # By getting the system time before we get the token we avoid a potential bug where the token may be expired. time_before_request = time.time() - # Post to the token server - response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify) + # Post to the token server, check if authorized + try: + response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify) + response.raise_for_status() + except requests.exceptions.HTTPError as err: + message = "Unable to fetch token: " + raise UnauthorizedTokenException(message + str(err), response.status_code) # If success get relevant data if response.status_code in [200, 201]: @@ -298,37 +329,15 @@

    Classes

    Methods

    -
    -def __init__(self, host_name, user_credentials, api_version='/rest/v1/', oauth=False, verify=True) -
    -
    -

    Initialize self. -See help(type(self)) for accurate signature.

    -
    -Source code -
    def __init__(self, host_name, user_credentials, api_version='/rest/v1/', oauth=False, verify=True):
    -    # Instance variables
    -    self.__api_version = api_version
    -    self.__host_name = host_name + self.__api_version
    -    self.__credentials = user_credentials
    -    self.__oauth = oauth
    -    self.__verify = verify
    -    self.__session = requests.Session()
    -
    -    # Setup OAuth if needed.
    -    if self.__oauth:
    -        self.__token_host = host_name + '/rest/oauth/token'
    -        self.__token = None
    -        self.__get_fresh_token()
    -
    -
    def delete(self, resource, **kwargs)
    -

    This method will perform a delete operation on the specified resource

    +

    This method will perform a delete operation on the specified resource

    -Source code + +Expand source code +
    def delete(self, resource, **kwargs):
         """ This method will perform a delete operation on the specified resource"""
         url = self.__host_name + resource
    @@ -346,9 +355,11 @@ 

    Methods

    def get(self, resource, params=None, **kwargs)
    -

    This method will perform a get operation on the specified resource

    +

    This method will perform a get operation on the specified resource

    -Source code + +Expand source code +
    def get(self, resource, params=None, **kwargs):
         """ This method will perform a get operation on the specified resource"""
         url = self.__host_name + resource
    @@ -366,9 +377,11 @@ 

    Methods

    def patch(self, resource, params=None, data=None, json=None, **kwargs)
    -

    This method will perform a patch operation to the specified resource

    +

    This method will perform a patch operation to the specified resource

    -Source code + +Expand source code +
    def patch(self, resource, params=None, data=None, json=None, **kwargs):
         """ This method will perform a patch operation to the specified resource"""
         url = self.__host_name + resource
    @@ -386,9 +399,11 @@ 

    Methods

    def post(self, resource, params=None, data=None, json=None, **kwargs)
    -

    This method will perform a post operation to the specified resource.

    +

    This method will perform a post operation to the specified resource.

    -Source code + +Expand source code +
    def post(self, resource, params=None, data=None, json=None, **kwargs):
         """ This method will perform a post operation to the specified resource."""
         url = self.__host_name + resource
    @@ -406,9 +421,11 @@ 

    Methods

    def put(self, resource, params=None, data=None, json=None, **kwargs)
    -

    This method will perform a put operation to the specified resource

    +

    This method will perform a put operation to the specified resource

    -Source code + +Expand source code +
    def put(self, resource, params=None, data=None, json=None, **kwargs):
         """ This method will perform a put operation to the specified resource"""
         url = self.__host_name + resource
    @@ -424,6 +441,55 @@ 

    Methods

    +
    +class CoreException +(message, status_code=None, reason=None) +
    +
    +

    This is the base class for all exceptions raised by the Core

    +
    + +Expand source code + +
    class CoreException(Exception):
    +    """This is the base class for all exceptions raised by the Core"""
    +
    +    def __init__(self, message, status_code=None, reason=None):
    +        super(CoreException, self).__init__(message)
    +        self.status_code = status_code
    +        self.reason = reason
    +
    +

    Ancestors

    +
      +
    • builtins.Exception
    • +
    • builtins.BaseException
    • +
    +

    Subclasses

    + +
    +
    +class UnauthorizedTokenException +(message, status_code=None, reason=None) +
    +
    +

    This exception is thrown whenever fetching the oauth token returns a 401 unauthorized response.

    +
    + +Expand source code + +
    class UnauthorizedTokenException(CoreException):
    +    """This exception is thrown whenever fetching the oauth token returns a 401 unauthorized response."""
    +    pass
    +
    +

    Ancestors

    + +
    @@ -442,8 +508,7 @@

    Index

    - - \ No newline at end of file diff --git a/docs/py_jama_rest_client/index.html b/docs/py_jama_rest_client/index.html index b5e28e1..8042b8a 100644 --- a/docs/py_jama_rest_client/index.html +++ b/docs/py_jama_rest_client/index.html @@ -3,21 +3,23 @@ - + py_jama_rest_client API documentation - - - - - + + + + + + +
    - - \ No newline at end of file diff --git a/py_jama_rest_client/client.py b/py_jama_rest_client/client.py index 0d2480c..8fd932c 100644 --- a/py_jama_rest_client/client.py +++ b/py_jama_rest_client/client.py @@ -863,6 +863,42 @@ def get_tagged_items(self, tag_id, allowed_results_per_page=__allowed_results_pe tag_results = self.__get_all(resource_path, params=params, allowed_results_per_page=allowed_results_per_page) return tag_results + def get_item_links(self, item_id): + """ + This method will return all links in the specified item. + Args: + item_id: the item ID + + Returns: a Json object with the links present in the item specified + + """ + resource_path = 'items/' + str(item_id) + '/links' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + + def get_filter_results_count(self, filter_id): + """ + This method will return count of items found through the specified filter. + Args: + filter_id: the filter ID + + Returns: a count of the items matched with the filter + + """ + resource_path = 'filters/' + str(filter_id) + '/count' + try: + response = self.__core.get(resource_path) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.json()['data'] + def get_users(self, allowed_results_per_page=__allowed_results_per_page): """ Gets a list of all active users visible to the current user @@ -1502,3 +1538,4 @@ def set_allowed_results_per_page(self, allowed_results_per_page): def get_allowed_results_per_page(self): return self.__allowed_results_per_page +