コード例 #1
0
	def get_list(self, database_client: DatabaseClient, # pylint: disable = too-many-arguments
			project: Optional[str] = None, job: Optional[str] = None,
			skip: int = 0, limit: Optional[int] = None, order_by: Optional[List[Tuple[str,str]]] = None) -> List[dict]:

		filter = { "project": project, "job": job } # pylint: disable = redefined-builtin
		filter = { key: value for key, value in filter.items() if value is not None }
		return database_client.find_many(self.table, filter, skip = skip, limit = limit, order_by = order_by)
コード例 #2
0
	def get_token_list(self, # pylint: disable = too-many-arguments
			database_client: DatabaseClient, user: Optional[str] = None,
			skip: int = 0, limit: Optional[int] = None, order_by: Optional[List[Tuple[str,str]]] = None) -> List[dict]:

		filter = { "user": user, "type": "token" } # pylint: disable = redefined-builtin
		filter = { key: value for key, value in filter.items() if value is not None }
		token_list = database_client.find_many(self.table, filter, skip = skip, limit = limit, order_by = order_by)
		return [ self.convert_to_public(token) for token in token_list ]
コード例 #3
0
	def get_list(self, database_client: DatabaseClient, # pylint: disable = too-many-arguments
			project: Optional[str] = None, job: Optional[str] = None, worker: Optional[str] = None, status: Optional[str] = None,
			skip: int = 0, limit: Optional[int] = None, order_by: Optional[List[Tuple[str,str]]] = None) -> List[dict]:

		filter = { "project": project, "job": job, "worker": worker, "status": status } # pylint: disable = redefined-builtin
		filter = { key: value for key, value in filter.items() if value is not None }
		run_collection = database_client.find_many(self.table, filter, skip = skip, limit = limit, order_by = order_by)
		return [ self.convert_to_public(run) for run in run_collection ]
コード例 #4
0
	def authenticate_with_token(self, database_client: DatabaseClient, user_identifier: str, secret: str) -> bool:
		now = self.date_time_provider.serialize(self.date_time_provider.now())
		user_tokens = database_client.find_many(self.table, { "user": user_identifier, "type": "token" })

		for token in user_tokens:
			if token["expiration_date"] is None or token["expiration_date"] > now:
				hashed_secret = self.hash_token(secret, token["hash_function"], token["hash_function_parameters"])
				if secrets.compare_digest(hashed_secret, token["secret"]):
					return True

		return False
コード例 #5
0
def export_table(database_client: DatabaseClient,
                 table: str,
                 output_directory: str,
                 simulate: bool = False) -> None:
    logger.info("Exporting table '%s'", table)

    dataset = database_client.find_many(table, {})
    output_file_path = os.path.join(output_directory, table + ".json")

    if not simulate:
        with open(output_file_path + ".tmp", mode="w",
                  encoding="utf-8") as output_file:
            json.dump(dataset, output_file, indent=4)
        os.replace(output_file_path + ".tmp", output_file_path)
コード例 #6
0
	def get_list(self, database_client: DatabaseClient,
			skip: int = 0, limit: Optional[int] = None, order_by: Optional[List[Tuple[str,str]]] = None) -> List[dict]:
		return database_client.find_many(self.table, {}, skip = skip, limit = limit, order_by = order_by)