rs_server_catalog/data_management/s3_manager.md
Module handling all operations on S3 bucket.
S3Manager
Tool class to handle all operations on S3 bucket.
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
check_s3_key(item, asset_name, s3_key)
Check if the given S3 key exists and matches the expected path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
dict
|
The item from the catalog (if it does exist) containing the asset. |
required |
asset_name
|
str
|
The name of the asset to check. |
required |
s3_key
|
str
|
The S3 key path to check against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the S3 key is valid and exists, otherwise False. |
NOTE |
int
|
Don't mind if we have RSPY_LOCAL_CATALOG_MODE set to ON (meaning self.s3_handler is None) |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If the s3_handler is not available, if S3 paths cannot be retrieved, if the S3 paths do not match, or if there is an error checking the key. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
clear_catalog_bucket(content)
Used to clear specific files from catalog bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
dict
|
Files to delete |
required |
s3_handler
|
S3StorageHandler
|
S3 handler to use. If None given, will do nothing |
required |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
delete_s3_files(s3_files_to_be_deleted)
Used to clear specific files from temporary bucket or from catalog bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s3_files_to_be_deleted
|
list[str]
|
list of files to delete from the S3 bucket |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True is deletion was successful, False otherwise |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
generate_presigned_url(content, path)
This function is used to generate a time-limited download url
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
dict
|
STAC description of the item to generate an URL for |
required |
path
|
str
|
Current path to this object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Presigned URL |
int |
int
|
HTTP return code |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
s3_bucket_handling(bucket_name, files_s3_key, item, request)
Handle the transfer and deletion of files in S3 buckets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name
|
str
|
Name of the S3 bucket to transfer files to |
required |
files_s3_key
|
list[str]
|
List of S3 keys for the files to be transfered. |
required |
item
|
dict
|
The catalog item from which all the remaining assets should be deleted. |
required |
request
|
Request
|
The request object, used to determine the request method. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
List of files to be deleted after a successful transfer |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If there are errors during the S3 transfer or deletion process. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
update_stac_item_publication(content, request, request_ids, item)
Update the JSON body of a feature push to the catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
dict
|
The content to update. |
required |
request
|
Request
|
The HTTP request object. |
required |
request_ids
|
dict
|
IDs associated to the given request |
required |
item
|
dict
|
The item from the catalog (if exists) to update. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated content. |
list |
list
|
List of files to delete from the S3 bucket |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If there are errors in processing the request, such as missing collection name, invalid S3 bucket, or failed file transfers. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
log_http_exception(*args, **kwargs)
Log error and return an HTTP exception to be raised by the caller
Source code in docs/rs-server/services/catalog/rs_server_catalog/data_management/s3_manager.py
49 50 51 | |