Exemple #1
0
    def add_extension(self, name, namespace, routing_key, exchange, patterns,
                      description=None):
        """Add an API extension service.

        :param str name: name of the new API extension service.
        :param str namespace: namespace of the new API extension service.
        :param str routing_key: AMQP routing key to use with the extension.
        :param str exchange: AMQP exchange to use with the extension.
        :param list patterns: list of url API filters to register with the
            extension.

        :return: object containing EntityType.ADMIN_SERVICE XML data i.e. the
            sparse representation of the API extension.

        :rtype: lxml.objectify.ObjectifiedElement
        """
        params = E_VMEXT.Service({'name': name})
        if description is not None:
            params.append(E.Description(description))
        params.append(E_VMEXT.Namespace(namespace))
        params.append(E_VMEXT.Enabled('true'))
        params.append(E_VMEXT.RoutingKey(routing_key))
        params.append(E_VMEXT.Exchange(exchange))
        filters = E_VMEXT.ApiFilters()
        for pattern in patterns:
            filters.append(
                E_VMEXT.ApiFilter(E_VMEXT.UrlPattern(pattern.strip())))
        params.append(filters)
        ext = self.client.get_extension()
        ext_services = self.client.get_linked_resource(
            ext, RelationType.DOWN, EntityType.EXTENSION_SERVICES.value)
        return self.client.post_linked_resource(ext_services, RelationType.ADD,
                                                EntityType.ADMIN_SERVICE.value,
                                                params)
Exemple #2
0
    def add_extension(self, name, namespace, routing_key, exchange, patterns):
        """Add an API extension.

        :param name: (str): The name of the new API extension service.
        :param namespace: (str): The namespace of the new API extension
            service.
        :param routing_key: (str): AMQP routing key to use with the extension.
        :param exchange: (str): AMQP exchange to use with the extension.
        :param patterns: (str): URI API filters to register with the extension.
        :return: (lxml.objectify.ObjectifiedElement): object containing
            the sparse representation of the API extension.
        """
        params = E_VMEXT.Service({'name': name})
        params.append(E_VMEXT.Namespace(namespace))
        params.append(E_VMEXT.Enabled('true'))
        params.append(E_VMEXT.RoutingKey(routing_key))
        params.append(E_VMEXT.Exchange(exchange))
        filters = E_VMEXT.ApiFilters()
        for pattern in patterns:
            filters.append(
                E_VMEXT.ApiFilter(E_VMEXT.UrlPattern(pattern.strip())))
        params.append(filters)
        ext = self.client.get_extension()
        ext_services = self.client.get_linked_resource(
            ext, RelationType.DOWN, EntityType.EXTENSION_SERVICES.value)
        return self.client.post_linked_resource(ext_services, RelationType.ADD,
                                                EntityType.ADMIN_SERVICE.value,
                                                params)
Exemple #3
0
 def add_extension(self, name, namespace, routing_key, exchange, patterns):
     params = E_VMEXT.Service({'name': name})
     params.append(E_VMEXT.Namespace(namespace))
     params.append(E_VMEXT.Enabled('true'))
     params.append(E_VMEXT.RoutingKey(routing_key))
     params.append(E_VMEXT.Exchange(exchange))
     filters = E_VMEXT.ApiFilters()
     for pattern in patterns:
         filters.append(
             E_VMEXT.ApiFilter(E_VMEXT.UrlPattern(pattern.strip())))
     params.append(filters)
     ext = self.client.get_extension()
     ext_services = self.client.get_linked_resource(
         ext, RelationType.DOWN, EntityType.EXTENSION_SERVICES.value)
     return self.client.post_linked_resource(ext_services, RelationType.ADD,
                                             EntityType.ADMIN_SERVICE.value,
                                             params)