add update_config() to view
authorDirk Thomas <dthomas@osrfoundation.org>
Thu, 20 Nov 2014 19:40:41 +0000 (11:40 -0800)
committerDirk Thomas <dthomas@osrfoundation.org>
Thu, 20 Nov 2014 19:46:11 +0000 (11:46 -0800)
jenkinsapi/view.py

index e06361f0a0c8053c4f3f166da4121e72e5b4ffee..69ecbf0dff34b822d6f9f8d35c7fe597f040995c 100644 (file)
@@ -167,6 +167,25 @@ class View(JenkinsBase):
     def get_nested_view_dict(self):
         return dict(self._get_nested_views())
 
+    def get_config_xml_url(self):
+        return '%s/config.xml' % self.baseurl
+
+    def update_config(self, config):
+        """
+        Update the config.xml to the view
+        """
+        url = self.get_config_xml_url()
+        try:
+            if isinstance(config, unicode):  # pylint: disable=undefined-variable
+                config = str(config)
+        except NameError:
+            # Python3 already a str
+            pass
+
+        response = self.get_jenkins_obj().requester.post_url(
+            url, params={}, data=config)
+        return response.text
+
     @property
     def views(self):
         return self.get_jenkins_obj().get_jenkins_obj_from_url(self.baseurl).views