Beispiel #1
0
    def obj_create(self, bundle, **kwargs):
        url, clusters = bundle.data['url'], bundle.data['clusters']
        purger = VarnishPurger()

        if not isinstance(clusters, list):
            clusters = [clusters]

        servers = ServerExtractor().extract_servers_by_clusters(LogicalCluster.objects.filter(name__in=clusters))
        raise ImmediateHttpResponse(self.create_json_response(purger.purge_url(url, servers), HttpResponse))
Beispiel #2
0
    def obj_create(self, bundle, **kwargs):
        url, clusters = bundle.data['url'], bundle.data['clusters']
        purger = VarnishPurger()

        if not isinstance(clusters, list):
            clusters = [clusters]

        servers = ServerExtractor().extract_servers_by_clusters(
            LogicalCluster.objects.filter(name__in=clusters))
        raise ImmediateHttpResponse(
            self.create_json_response(purger.purge_url(url, servers),
                                      HttpResponse))
Beispiel #3
0
    def obj_create(self, bundle, **kwargs):
        try:
            if not bundle.request.user.is_staff:
                raise Unauthorized()
        except Unauthorized as e:
            self.unauthorized_result(e)

        url, clusters = bundle.data['url'], bundle.data['clusters']
        purger = VarnishPurger()

        if not isinstance(clusters, list):
            clusters = [clusters]

        servers = ServerExtractor().extract_servers_by_clusters(
            LogicalCluster.objects.filter(name__in=clusters))
        raise ImmediateHttpResponse(
            self.create_json_response(purger.purge_url(url, servers),
                                      HttpResponse))
Beispiel #4
0
    def obj_create(self, bundle, **kwargs):
        try:
            if not bundle.request.user.is_staff:
                raise Unauthorized()
        except Unauthorized as e:
            self.unauthorized_result(e)
        self.is_valid(bundle)
        if bundle.errors:
            raise ImmediateHttpResponse(response=self.error_response(bundle.request, bundle.errors))
        url, clusters, headers = bundle.data['url'], bundle.data['clusters'], bundle.data.get('headers')
        purger = VarnishPurger()

        if not isinstance(clusters, list):
            clusters = [clusters]

        servers = ServerExtractor().extract_servers_by_clusters(LogicalCluster.objects.filter(name__in=clusters))
        purger_result = purger.purge_url(url, servers, headers)
        if len(purger_result.get("error")) > 0:
            raise ImmediateHttpResponse(self.create_json_response(purger_result, HttpApplicationError))
        raise ImmediateHttpResponse(self.create_json_response(purger_result, HttpResponse))