Пример #1
0
 def delete_node(self, node_id):
     """
     :param node_id: 5-character node id
     :return: none
     """
     get_response_or_exception('delete',
                               '{}nodes/{}/'.format(self.root_url, node_id),
                               auth=self.auth)
Пример #2
0
 def delete_node(self, node_id):
     """
     :param node_id: 5-character node id
     :return: none
     """
     get_response_or_exception(
         'delete', '{}nodes/{}/'.format(self.root_url, node_id),
         auth=self.auth
     )
Пример #3
0
 def get_root(self):
     """
     :return: a DotNotator object of the api root as designated
     by self.root_url
     """
     response = get_response_or_exception('get', self.root_url)
     response_json = response.json()
     return DotNotator(response_json)
Пример #4
0
 def get_root(self):
     """
     :return: a DotNotator object of the api root as designated
     by self.root_url
     """
     response = get_response_or_exception('get', self.root_url)
     response_json = response.json()
     return DotNotator(response_json)
Пример #5
0
 def get_user(self, user_id):
     """
     :param user_id: 5-character user id
     :return: the user identified by user_id
     """
     url = '{}users/{}/'.format(self.root_url, user_id)
     response = get_response_or_exception('get', url, auth=self.auth)
     data = response.json()[u'data']
     return DotNotator(data)
Пример #6
0
 def get_user(self, user_id):
     """
     :param user_id: 5-character user id
     :return: the user identified by user_id
     """
     url = '{}users/{}/'.format(self.root_url, user_id)
     response = get_response_or_exception('get', url, auth=self.auth)
     data = response.json()[u'data']
     return DotNotator(data)
Пример #7
0
 def get_node(self, node_id=''):
     """
     :param node_id: 5-character id for a node that can be
     viewed by this session's auth
     :return: the node identified by node_id
     """
     url = '{}nodes/{}/'.format(self.root_url, node_id)
     response = get_response_or_exception('get', url, auth=self.auth)
     data = response.json()[u'data']
     return DotNotator(data)
Пример #8
0
 def get_node(self, node_id=''):
     """
     :param node_id: 5-character id for a node that can be
     viewed by this session's auth
     :return: the node identified by node_id
     """
     url = '{}nodes/{}/'.format(self.root_url, node_id)
     response = get_response_or_exception('get', url, auth=self.auth)
     data = response.json()[u'data']
     return DotNotator(data)
Пример #9
0
 def edit_node(self, node_id, **kwargs):
     """
     :param node_id: 5-character id for a node that can be
     edited by this session's auth
     :param kwargs: e.g. title='My Title',
     description='This is my new description',
     category='data'
     :return: DotNotator version of edited node
     """
     # e.g. kwargs: title='', description='', category=''
     params = {}
     for key, value in kwargs.items():
         params[key] = value
     edited_node = get_response_or_exception(
         'patch', '{}nodes/{}/'.format(self.root_url, node_id),
         json=params,
         auth=self.auth
     )
     edited_node_json = edited_node.json()[u'data']
     return DotNotator(edited_node_json)
Пример #10
0
 def edit_node(self, node_id, **kwargs):
     """
     :param node_id: 5-character id for a node that can be
     edited by this session's auth
     :param kwargs: e.g. title='My Title',
     description='This is my new description',
     category='data'
     :return: DotNotator version of edited node
     """
     # e.g. kwargs: title='', description='', category=''
     params = {}
     for key, value in kwargs.items():
         params[key] = value
     edited_node = get_response_or_exception('patch',
                                             '{}nodes/{}/'.format(
                                                 self.root_url, node_id),
                                             json=params,
                                             auth=self.auth)
     edited_node_json = edited_node.json()[u'data']
     return DotNotator(edited_node_json)
Пример #11
0
 def create_node(self, title, description="",
                 category=""):
     """
     :param title: required, string
     :param description: optional, string
     :param category: optional, choice of '', 'project',
     'hypothesis', 'methods and measures', 'procedure',
     'instrumentation', 'data', 'analysis', 'communication',
     'other'
     :return: DotNotator version of created node
     """
     # TODO once functionality exists to create public nodes w/ API,
     # add 'public' bool to create_node parameters, and add the
     # functionality in this method.
     params = {'title': title, 'description': description,
               'category': category}
     node = get_response_or_exception(
         'post', '{}nodes/'.format(self.root_url),
         json=params, auth=self.auth
     )
     node_json = node.json()[u'data']
     return DotNotator(node_json)
Пример #12
0
 def create_node(self, title, description="", category=""):
     """
     :param title: required, string
     :param description: optional, string
     :param category: optional, choice of '', 'project',
     'hypothesis', 'methods and measures', 'procedure',
     'instrumentation', 'data', 'analysis', 'communication',
     'other'
     :return: DotNotator version of created node
     """
     # TODO once functionality exists to create public nodes w/ API,
     # add 'public' bool to create_node parameters, and add the
     # functionality in this method.
     params = {
         'title': title,
         'description': description,
         'category': category
     }
     node = get_response_or_exception('post',
                                      '{}nodes/'.format(self.root_url),
                                      json=params,
                                      auth=self.auth)
     node_json = node.json()[u'data']
     return DotNotator(node_json)