Beispiel #1
0
	def delete(self, database_client: DatabaseClient,
			user_identifier: str, authentication_provider: AuthenticationProvider, worker_provider: WorkerProvider) -> None:

		user_record = self.get(database_client, user_identifier)
		if user_record is None:
			raise ValueError("User '%s' does not exist" % user_identifier)
		if user_record["is_enabled"]:
			raise ValueError("User '%s' is enabled" % user_identifier)
		if worker_provider.count(database_client, owner = user_identifier) > 0:
			raise ValueError("User '%s' owns workers" % user_identifier)

		authentication_provider.remove_password(database_client, user_identifier)
		for token in authentication_provider.get_token_list(database_client, user_identifier):
			authentication_provider.delete_token(database_client, user_identifier, token["identifier"])
		database_client.delete_one(self.table, { "identifier": user_identifier })
Beispiel #2
0
    def delete(self, database_client: DatabaseClient, worker_identifier: str,
               run_provider: RunProvider) -> None:
        worker_record = self.get(database_client, worker_identifier)
        if worker_record is None:
            raise ValueError("Worker '%s' does not exist" % worker_identifier)

        if worker_record["is_enabled"]:
            raise ValueError("Worker '%s' is enabled" % worker_identifier)
        if worker_record["is_active"]:
            raise ValueError("Worker '%s' is active" % worker_identifier)

        if run_provider.count(worker=worker_identifier, status="pending") > 0:
            raise ValueError("Worker '%s' has pending runs" %
                             worker_identifier)
        if run_provider.count(worker=worker_identifier, status="running") > 0:
            raise ValueError("Worker '%s' has running runs" %
                             worker_identifier)

        database_client.delete_one(self.table,
                                   {"identifier": worker_identifier})
Beispiel #3
0
	def remove_password(self, database_client: DatabaseClient, user: str) -> None:
		database_client.delete_one(self.table, { "user": user, "type": "password" })
Beispiel #4
0
	def delete_token(self, database_client: DatabaseClient, user_identifier: str, token_identifier: str) -> None:
		database_client.delete_one(self.table, { "identifier": token_identifier, "user": user_identifier, "type": "token" })
 def delete(self, database_client: DatabaseClient, project: str,
            job_identifier: str) -> None:
     database_client.delete_one(self.table, {
         "project": project,
         "identifier": job_identifier
     })