|
16 | 16 | Operation, |
17 | 17 | ) |
18 | 18 | from job_executor.common.exceptions import HttpRequestError, HttpResponseError |
19 | | -from job_executor.config import environment |
| 19 | +from job_executor.config import environment, secrets |
20 | 20 |
|
21 | 21 | DATASTORE_API_URL = environment.datastore_api_url |
22 | 22 | DEFAULT_REQUESTS_TIMEOUT = (10, 60) # (read timeout, connect timeout) |
| 23 | +DATASTORE_API_SERVICE_KEY = secrets.datastore_api_service_key |
23 | 24 |
|
24 | 25 | logger = logging.getLogger() |
25 | 26 |
|
@@ -117,6 +118,25 @@ def get_datastore_directory(rdn: str) -> Path: |
117 | 118 | return Path(DatastoreResponse.model_validate(response.json()).directory) |
118 | 119 |
|
119 | 120 |
|
| 121 | +def post_public_key(datastore_rdn: str, public_key_pem: bytes) -> None: |
| 122 | + """ |
| 123 | + Post the public RSA key to the datastore-api. |
| 124 | +
|
| 125 | + :param datastore_rdn: The RDN of the datastore |
| 126 | + :param public_key_pem: The public key in PEM format as bytes |
| 127 | + """ |
| 128 | + request_url = f"{DATASTORE_API_URL}/datastores/{datastore_rdn}/public-key" |
| 129 | + execute_request( |
| 130 | + "POST", |
| 131 | + request_url, |
| 132 | + data=public_key_pem, |
| 133 | + headers={ |
| 134 | + "Content-Type": "application/x-pem-file", |
| 135 | + "X-API-Key": DATASTORE_API_SERVICE_KEY, |
| 136 | + }, |
| 137 | + ) |
| 138 | + |
| 139 | + |
120 | 140 | def query_for_jobs() -> JobQueryResult: |
121 | 141 | """ |
122 | 142 | Retrieves different types of jobs based on the system's state |
@@ -147,6 +167,7 @@ def query_for_jobs() -> JobQueryResult: |
147 | 167 | Operation.REMOVE, |
148 | 168 | Operation.ROLLBACK_REMOVE, |
149 | 169 | Operation.DELETE_ARCHIVE, |
| 170 | + Operation.GENERATE_RSA_KEYS, |
150 | 171 | ], |
151 | 172 | ), |
152 | 173 | queued_worker_jobs=get_jobs( |
|
0 commit comments