Exemple #1
0
    def DELETE(self, repo_id, distributor_id, schedule_id):
        distributor_manager = manager_factory.repo_distributor_manager()
        schedule_list = distributor_manager.list_publish_schedules(repo_id, distributor_id)
        if schedule_id not in schedule_list:
            raise exceptions.MissingResource(repo=repo_id, distributor=distributor_id, publish_schedule=schedule_id)

        schedule_manager = manager_factory.schedule_manager()
        resources = {
            dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_READ_OPERATION},
            dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {
                distributor_id: dispatch_constants.RESOURCE_UPDATE_OPERATION
            },
            dispatch_constants.RESOURCE_SCHEDULE_TYPE: {schedule_id: dispatch_constants.RESOURCE_DELETE_OPERATION},
        }
        tags = [
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
            resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
            action_tag("delete_publish_schedule"),
        ]
        call_request = CallRequest(
            schedule_manager.delete_publish_schedule,
            [repo_id, distributor_id, schedule_id],
            resources=resources,
            tags=tags,
            archive=True,
        )
        return execution.execute_ok(self, call_request)
Exemple #2
0
    def PUT(self, repo_id, distributor_id):

        # Params (validation will occur in the manager)
        params = self.params()
        distributor_config = params.get("distributor_config", None)

        if distributor_config is None:
            _LOG.exception(
                "Missing configuration when updating distributor [%s] on repository [%s]" % (distributor_id, repo_id)
            )
            raise exceptions.MissingValue(["distributor_config"])

        distributor_manager = manager_factory.repo_distributor_manager()
        resources = {
            dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION},
            dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {
                distributor_id: dispatch_constants.RESOURCE_UPDATE_OPERATION
            },
        }
        tags = [
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
            action_tag("update_distributor"),
        ]
        call_request = CallRequest(
            distributor_manager.update_distributor_config,
            [repo_id, distributor_id, distributor_config],
            resources=resources,
            tags=tags,
            archive=True,
        )
        return execution.execute_ok(self, call_request)
Exemple #3
0
    def PUT(self, repo_id, importer_id):

        # Params (validation will occur in the manager)
        params = self.params()
        importer_config = params.get("importer_config", None)

        if importer_config is None:
            _LOG.exception("Missing configuration updating importer for repository [%s]" % repo_id)
            raise exceptions.MissingValue(["importer_config"])

        importer_manager = manager_factory.repo_importer_manager()
        resources = {
            dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION},
            dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE: {
                importer_id: dispatch_constants.RESOURCE_UPDATE_OPERATION
            },
        }
        tags = [
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id),
            action_tag("update_importer"),
        ]
        call_request = CallRequest(
            importer_manager.update_importer_config,
            [repo_id, importer_config],
            resources=resources,
            tags=tags,
            archive=True,
        )
        return execution.execute_ok(self, call_request)
Exemple #4
0
    def DELETE(self, id):
        repo_manager = manager_factory.repo_manager()
        resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id), action_tag("delete")]

        call_request = CallRequest(repo_manager.delete_repo, [id], resources=resources, tags=tags, archive=True)
        return execution.execute_ok(self, call_request)
Exemple #5
0
    def POST(self, repo_id):

        # Collect user input
        params = self.params()
        upload_id = params["upload_id"]
        unit_type_id = params["unit_type_id"]
        unit_key = params["unit_key"]
        unit_metadata = params.pop("unit_metadata", None)

        # Coordinator configuration
        resources = {
            dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}
        }
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag("import_upload")]

        upload_manager = manager_factory.content_upload_manager()
        call_request = CallRequest(
            upload_manager.import_uploaded_unit,
            [repo_id, unit_type_id, unit_key, unit_metadata, upload_id],
            resources=resources,
            tags=tags,
            archive=True,
        )

        return execution.execute_ok(self, call_request)
Exemple #6
0
 def DELETE(self, repo_group_id):
     manager = managers_factory.repo_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)]
     call_request = CallRequest(manager.delete_repo_group,
                                [repo_group_id],
                                tags=tags)
     call_request.deletes_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id)
     return execution.execute_ok(self, call_request)
Exemple #7
0
 def DELETE(self, consumer_group_id):
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)]
     call_request = CallRequest(manager.delete_consumer_group,
                                [consumer_group_id],
                                tags=tags)
     call_request.deletes_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     return execution.execute_ok(self, call_request)
Exemple #8
0
    def DELETE(self, login):

        manager = managers.user_manager()

        resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login),
                action_tag('delete')]
        call_request = CallRequest(manager.delete_user,
                                   [login],
                                   resources=resources,
                                   tags=tags)
        return execution.execute_ok(self, call_request)
Exemple #9
0
    def PUT(self, login):

        # Pull all the user update data
        user_data = self.params()
        delta = user_data.get("delta", None)

        # Perform update
        manager = managers.user_manager()
        resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_UPDATE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login), action_tag("update")]
        call_request = CallRequest(manager.update_user, [login, delta], resources=resources, tags=tags)
        return execution.execute_ok(self, call_request)
Exemple #10
0
    def DELETE(self, login):

        manager = managers.user_manager()

        resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login), action_tag("delete")]
        call_request = CallRequest(manager.delete_user, [login], resources=resources, tags=tags)
        # Remove permissions
        user_link = serialization.link.current_link_obj()
        permission_manager = managers.permission_manager()
        permission_manager.delete_permission(user_link["_href"])
        return execution.execute_ok(self, call_request)
Exemple #11
0
 def DELETE(self, repo_id, distributor_id):
     distributor_manager = manager_factory.repo_distributor_manager()
     resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION},
                  dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE: {distributor_id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
     tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
             resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
             action_tag('remove_distributor')]
     call_request = CallRequest(distributor_manager.remove_distributor,
                                [repo_id, distributor_id],
                                resources=resources,
                                tags=tags,
                                archive=True)
     return execution.execute_ok(self, call_request)
Exemple #12
0
    def DELETE(self, repo_id, importer_id):

        importer_manager = manager_factory.repo_importer_manager()
        resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION},
                     dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE: {importer_id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id),
                action_tag('delete_importer')]
        call_request = CallRequest(importer_manager.remove_importer,
                                   [repo_id],
                                   resources=resources,
                                   tags=tags,
                                   archive=True)
        return execution.execute_ok(self, call_request)
Exemple #13
0
    def DELETE(self, consumer_id, schedule_id):
        consumer_manager = managers.consumer_manager()
        consumer_manager.get_consumer(consumer_id)

        schedule_manager = managers.schedule_manager()

        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
                action_tag('delete_unit_update_schedule')]

        call_request = CallRequest(schedule_manager.delete_unit_update_schedule,
                                   [consumer_id, schedule_id],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
        call_request.deletes_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)

        return execution.execute_ok(self, call_request)
Exemple #14
0
    def DELETE(self, repo_id, importer_id, schedule_id):
        importer_manager = manager_factory.repo_importer_manager()
        schedule_list = importer_manager.list_sync_schedules(repo_id)
        if schedule_id not in schedule_list:
            raise exceptions.MissingResource(repo=repo_id, importer=importer_id, publish_schedule=schedule_id)

        schedule_manager = manager_factory.schedule_manager()
        resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_READ_OPERATION},
                     dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE: {importer_id: dispatch_constants.RESOURCE_UPDATE_OPERATION},
                     dispatch_constants.RESOURCE_SCHEDULE_TYPE: {schedule_id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
        tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
                resource_tag(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id),
                resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
                action_tag('delete_sync_schedule')]
        call_request = CallRequest(schedule_manager.delete_sync_schedule,
                                   [repo_id, importer_id, schedule_id],
                                   resources=resources,
                                   tags=tags,
                                   archive=True)
        return execution.execute_ok(self, call_request)