-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathunsuppress_miro.py
59 lines (46 loc) · 1.71 KB
/
unsuppress_miro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import click
from miro_updates import unsuppress_image, is_valid_miro_id
@click.command()
@click.argument("id")
@click.option(
"--origin",
help="URL of the image",
required=True,
)
@click.option(
"--message",
help="Why the image was reinstated, a link to a Slack message, etc.",
required=True,
)
def unsuppress_miro(id, origin, message):
"""
Reinstates a previously suppressed Miro image with a given ID and origin
ID is a MIRO identifier
origin is the URL of the image it corresponds to.
Prerequisites:
- You have a MIRO id you wish to reinstate.
- Find the image in the Storage Service bucket
- Configure the pipeline to listen to the reindexer
Usage:
- provide the MIRO id as --id
- provide the https://s3... URL for the image as --origin
- give a reason or link in --message
thus:
python unsuppress_miro.py --id L0099099 --origin https://s3-.../L0099099.JP2 --message "because I say so"
This may fail with a message
"Delivery channels are required when updating an existing Asset via PUT"
This indicates that the image in question is already on DLCS (though it may be in an error state).
If you are confident that it is not working, and you wish it to be, suppress it
(specifically, this is in order remove it from DLCS) and try again.
"""
id = id.strip()
if is_valid_miro_id(id):
miro_id = id
else:
raise click.ClickException(
f"{id} doesn't look like a Miro ID and isn't the identifier of a catalogue record containing a Miro ID"
)
unsuppress_image(miro_id=miro_id, origin=origin, message=message)
if __name__ == "__main__":
unsuppress_miro()