-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PB-756: API to upload collection assets
Add upload endpoints for collection assets. Mostly a duplication of the already existing multipart upload endpoints.
- Loading branch information
Showing
10 changed files
with
2,103 additions
and
37 deletions.
There are no files selected for viewing
137 changes: 137 additions & 0 deletions
137
app/stac_api/migrations/0050_collectionassetupload_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Generated by Django 5.0.8 on 2024-09-09 10:59 | ||
|
||
import pgtrigger.compiler | ||
import pgtrigger.migrations | ||
|
||
import django.core.serializers.json | ||
import django.core.validators | ||
import django.db.models.deletion | ||
from django.db import migrations | ||
from django.db import models | ||
|
||
import stac_api.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('stac_api', '0049_item_properties_expires'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CollectionAssetUpload', | ||
fields=[ | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('upload_id', models.CharField(max_length=255)), | ||
( | ||
'status', | ||
models.CharField( | ||
choices=[(None, ''), ('in-progress', 'In Progress'), | ||
('completed', 'Completed'), ('aborted', 'Aborted')], | ||
default='in-progress', | ||
max_length=32 | ||
) | ||
), | ||
( | ||
'number_parts', | ||
models.IntegerField( | ||
validators=[ | ||
django.core.validators.MinValueValidator(1), | ||
django.core.validators.MaxValueValidator(100) | ||
] | ||
) | ||
), | ||
( | ||
'md5_parts', | ||
models.JSONField( | ||
editable=False, encoder=django.core.serializers.json.DjangoJSONEncoder | ||
) | ||
), | ||
( | ||
'urls', | ||
models.JSONField( | ||
blank=True, | ||
default=list, | ||
encoder=django.core.serializers.json.DjangoJSONEncoder | ||
) | ||
), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
('ended', models.DateTimeField(blank=True, default=None, null=True)), | ||
('checksum_multihash', models.CharField(max_length=255)), | ||
('etag', models.CharField(default=stac_api.models.compute_etag, max_length=56)), | ||
( | ||
'update_interval', | ||
models.IntegerField( | ||
default=-1, | ||
help_text= | ||
'Interval in seconds in which the asset data is updated.-1 means that the data is not on a regular basis updated.This field can only be set via the API.', | ||
validators=[django.core.validators.MinValueValidator(-1)] | ||
) | ||
), | ||
( | ||
'content_encoding', | ||
models.CharField( | ||
blank=True, | ||
choices=[(None, ''), ('gzip', 'Gzip'), ('br', 'Br')], | ||
default='', | ||
max_length=32 | ||
) | ||
), | ||
( | ||
'asset', | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='+', | ||
to='stac_api.collectionasset' | ||
) | ||
), | ||
], | ||
), | ||
migrations.AddConstraint( | ||
model_name='collectionassetupload', | ||
constraint=models.UniqueConstraint( | ||
fields=('asset', 'upload_id'), | ||
name='unique_asset_upload_collection_asset_upload_id' | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name='collectionassetupload', | ||
constraint=models.UniqueConstraint( | ||
condition=models.Q(('status', 'in-progress')), | ||
fields=('asset', 'status'), | ||
name='unique_asset_upload_in_progress' | ||
), | ||
), | ||
pgtrigger.migrations.AddTrigger( | ||
model_name='collectionassetupload', | ||
trigger=pgtrigger.compiler.Trigger( | ||
name='add_asset_upload_trigger', | ||
sql=pgtrigger.compiler.UpsertTriggerSql( | ||
func= | ||
'\n -- update AssetUpload auto variable\n NEW.etag = public.gen_random_uuid();\n\n RETURN NEW;\n ', | ||
hash='5f51ec3c72c4d9fbe6b81d2fd881dd5228dc80bf', | ||
operation='INSERT', | ||
pgid='pgtrigger_add_asset_upload_trigger_8330c', | ||
table='stac_api_collectionassetupload', | ||
when='BEFORE' | ||
) | ||
), | ||
), | ||
pgtrigger.migrations.AddTrigger( | ||
model_name='collectionassetupload', | ||
trigger=pgtrigger.compiler.Trigger( | ||
name='update_asset_upload_trigger', | ||
sql=pgtrigger.compiler.UpsertTriggerSql( | ||
condition='WHEN (OLD.* IS DISTINCT FROM NEW.*)', | ||
func= | ||
'\n -- update AssetUpload auto variable\n NEW.etag = public.gen_random_uuid();\n\n RETURN NEW;\n ', | ||
hash='0a7f1aa8f8c0bb2c413a7ce626f75c8da5bf4b6d', | ||
operation='UPDATE', | ||
pgid='pgtrigger_update_asset_upload_trigger_8d012', | ||
table='stac_api_collectionassetupload', | ||
when='BEFORE' | ||
) | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.