# Path: gocdapi/custom_exceptions.py
# class GoCdApiException(Exception):
#     """
#     Base class for all errors
#     """
#     pass


import xml.etree.ElementTree as ET
from gocdapi.custom_exceptions import GoCdApiException
            GoCdApiException: When no pipeline with the pipeline_name exists
        """
        pipeline_element = self.get_pipeline(pipeline_name)
        if pipeline_element is None:
            raise GoCdApiException("Pipeline '%s' doesn't exist." % pipeline_name)

        group_element = self.get_pipeline_parent_group(pipeline_name)
        group_element.remove(pipeline_element)
        return group_element

    def update_pipeline_element(self, pipeline_element):
        """ Replaces an existent pipeline element by a new one

        Args:
            pipeline_element (str): new pipeline Element to replace the existent one
        """
        pipeline_name = pipeline_element.get("name")
        group_element = self.remove_pipeline(pipeline_name)
        group_element.append(pipeline_element)

    def add_pipeline_group_element(self, group_element):
        """ Adds a pipeline group Element to the configuration

        Args:
            pipeline_element (ElementTree.Element): pipeline group to be added

        Raises:
            GoCdApiException: When a pipeline group with the group_name already exists
        """
        if self.get_pipeline_group(group_element.get('group')) is not None:

# Path: gocdapi/custom_exceptions.py
# class GoCdApiException(Exception):
#     """
#     Base class for all errors
#     """
#     pass


# Path: gocdapi/utils/config_xml.py
import xml.etree.ElementTree as ET
from gocdapi.custom_exceptions import GoCdApiException

            GoCdApiException: When no pipeline with the pipeline_name exists
        """
        pipeline_element = self.get_pipeline(pipeline_name)
        if pipeline_element is None:
            raise GoCdApiException("Pipeline '%s' doesn't exist." % pipeline_name)

        group_element = self.get_pipeline_parent_group(pipeline_name)
        group_element.remove(pipeline_element)
        return group_element

    def update_pipeline_element(self, pipeline_element):
        """ Replaces an existent pipeline element by a new one

        Args:
            pipeline_element (str): new pipeline Element to replace the existent one
        """
        pipeline_name = pipeline_element.get("name")
        group_element = self.remove_pipeline(pipeline_name)
        group_element.append(pipeline_element)

    def add_pipeline_group_element(self, group_element):
        """ Adds a pipeline group Element to the configuration

        Args:
            pipeline_element (ElementTree.Element): pipeline group to be added

        Raises:
            GoCdApiException: When a pipeline group with the group_name already exists
        """
        if self.get_pipeline_group(group_element.get('group')) is not None:

            raise GoCdApiException("Pipeline group '%s' already exists." % group_element.get('group'))