コード例 #1
0
ファイル: consumers.py プロジェクト: zjhuntin/pulp
    def post(self, request, consumer_id):
        """
        Create a schedule.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :param consumer_id: The consumer ID.
        :type consumer_id: str

        :raises UnsupportedValue: if some extra unsupported keys were specified.

        :return: Response containing just created schedule
        :rtype: django.http.HttpResponse
        """

        params = request.body_as_json
        units = params.pop('units', None)
        options = params.pop('options', {})
        schedule = params.pop('schedule', None)
        failure_threshold = params.pop('failure_threshold', None)
        enabled = params.pop('enabled', True)
        if params:
            raise UnsupportedValue(params.keys())
        scheduled_call = self.manager.create_schedule(self.ACTION, consumer_id,
                                                      units, options, schedule,
                                                      failure_threshold,
                                                      enabled)

        scheduled_obj = scheduled_unit_management_obj(
            scheduled_call.for_display())
        link = add_link_schedule(scheduled_obj, self.ACTION, consumer_id)
        response = generate_json_response_with_pulp_encoder(scheduled_obj)
        redirect_response = generate_redirect_response(response, link['_href'])
        return redirect_response
コード例 #2
0
ファイル: consumers.py プロジェクト: ipanova/pulp
    def POST(self, consumer_id):
        params = self.params()
        units = params.pop('units', None)
        options = params.pop('options', {})
        schedule = params.pop('schedule', None)
        failure_threshold = params.pop('failure_threshold', None)
        enabled = params.pop('enabled', True)
        if params:
            raise UnsupportedValue(params.keys())

        scheduled_call = self.manager.create_schedule(
            self.ACTION, consumer_id, units, options, schedule, failure_threshold, enabled)

        scheduled_obj = serialization.dispatch.scheduled_unit_management_obj(
            scheduled_call.for_display())
        scheduled_obj.update(serialization.link.child_link_obj(scheduled_call.id))
        return self.created(scheduled_obj['_href'], scheduled_obj)