granicus_archiver.aws¶
granicus_archiver.aws.client¶
- class granicus_archiver.aws.client.ClientBase(config: Config)[source]¶
Bases:
objectBase class for AWS clients
- Parameters:
config (Config)
- s3_resource: S3ServiceResource¶
The S3 service resource
- s3_client: S3Client¶
The S3 client
- bucket: Bucket¶
The S3 bucket
- session: Session¶
The boto3 session
- url_for_key(key: str | Path, scheme: str | None = None) URL[source]¶
Get a URL for an S3 key within
bucket
- async get_object(key: str | Path) Object[source]¶
Get an S3 object within
bucketby key- Parameters:
key (str | Path)
- Return type:
Object
- async iter_objects(prefix: Path | str) AsyncGenerator[ObjectSummary, None][source]¶
Iterate over objects in
bucketwith a given (optional) prefix- Parameters:
prefix (Path | str)
- Return type:
AsyncGenerator[ObjectSummary, None]
- async get_object_tags(obj: Object | str | Path) dict[str, str][source]¶
Get the tags for an S3 object
- async get_object_sha1(obj: Object | str | Path) SHA1Hash | None[source]¶
Get the SHA1 hash for an S3 object
- Parameters:
obj (Object | str | Path)
- Return type:
SHA1Hash | None
- async check_object_hash(obj: Object | str | Path, local_hash: SHA1Hash) None[source]¶
Check the SHA1 hash of an S3 object against a local hash
- Raises:
HashMismatchError – If the hashes do not match
- Parameters:
obj (Object | str | Path)
local_hash (SHA1Hash)
- Return type:
None
- async upload(key: str | Path, local_filename: Path, wait_exists: bool = True, check_exists: bool = True, local_meta: FileMeta | None = None, acl: Literal['private', 'public-read', 'public-read-write', 'authenticated-read', 'aws-exec-read', 'bucket-owner-read', 'bucket-owner-full-control'] | None = None) Object[source]¶
- async upload(key: str | Path, local_filename: Path, wait_exists: bool = True, check_exists: bool = True, local_meta: FileMeta | None = None, acl: Literal['private', 'public-read', 'public-read-write', 'authenticated-read', 'aws-exec-read', 'bucket-owner-read', 'bucket-owner-full-control'] | None = None) Object
- async upload(key: str | Path, local_filename: Path, wait_exists: bool = False, check_exists: bool = True, local_meta: FileMeta | None = None, acl: Literal['private', 'public-read', 'public-read-write', 'authenticated-read', 'aws-exec-read', 'bucket-owner-read', 'bucket-owner-full-control'] | None = None) str | Path
Upload a file to S3
- Parameters:
key – The S3 key to upload the file to
local_filename – The local file to upload
wait_exists – If
True, wait for the object to exist before returningcheck_exists – If
True, check if the object exists before uploadinglocal_meta – The metadata for the local file
acl – The ACL for the uploaded object
- class granicus_archiver.aws.client.ClipClient(config: Config, max_clips: int = 8, scheduler_limit: int = 8)[source]¶
Bases:
ClientBaseAWS Client to upload items from a
model.ClipCollection- property upload_dir: Path¶
Root folder name (key prefix) for uploaded clips (alias for
config.AWSConfig.clips_prefix)
- get_clip_file_upload_path(clip: Clip, key: Literal['agenda', 'minutes', 'audio', 'video', 'chapters', 'agenda_packet']) Path[source]¶
Get the uploaded filename for a clip asset (relative to
upload_dir)
- async upload_clip(clip: Clip, *file_keys: Literal['agenda', 'minutes', 'audio', 'video', 'chapters', 'agenda_packet']) bool[source]¶
Upload all assets for the given clip
- async check_clip_needs_upload(clip: Clip) tuple[bool, Clip, set[Literal['agenda', 'minutes', 'audio', 'video', 'chapters', 'agenda_packet']]][source]¶
Check if the given clip hash any assets that need to be uploaded
- async handle_upload_check_jobs() None[source]¶
Wait for jobs from
check_clip_needs_upload()and spawns theirupload_clip()jobs- Return type:
None
- async upload_all(clips: ClipCollection) None[source]¶
Upload assets for the given clips (up to by
max_clips)- Parameters:
clips (ClipCollection)
- Return type:
None
- class granicus_archiver.aws.client.LegistarClientBase(config: Config, max_clips: int, legistar_data: _ModelT | None = None)[source]¶
Bases:
ClientBase,Generic[_GuidT,_ItemT,_ModelT],ABC- legistar_data: _ModelT¶
A
AbstractLegistarModelinstance
- get_file_upload_path(guid: _GuidT, uid: LegistarFileUID) Path[source]¶
Get the uploaded filename for a legistar asset (relative to
upload_dir)- Parameters:
guid (_GuidT)
uid (LegistarFileUID)
- Return type:
Path
- async upload_legistar_file(guid: _GuidT, uid: LegistarFileUID, local_file: Path, local_meta: FileMeta) bool[source]¶
Upload a single legistar file
- Parameters:
guid (_GuidT)
uid (LegistarFileUID)
local_file (Path)
local_meta (FileMeta)
- Return type:
- async upload_legistar_item(guid: _GuidT, *uids: LegistarFileUID) bool[source]¶
Upload all assets for the legistar item matching the given guid
- Parameters:
guid (_GuidT)
uids (LegistarFileUID)
- Return type:
- async check_item_needs_upload(guid: _GuidT) tuple[bool, _GuidT, set[LegistarFileUID]][source]¶
Check if the item matching guid has any local files that need to be uploaded
- async handle_upload_check_jobs() None[source]¶
Wait for jobs from
check_item_needs_upload()and spawns theirupload_legistar_item()jobs- Return type:
None
- async upload_all() None[source]¶
Upload files for all items in
legistar_data(up to bymax_clips)- Return type:
None
- class granicus_archiver.aws.client.LegistarClient(config: Config, max_clips: int, legistar_data: _ModelT | None = None)[source]¶
Bases:
LegistarClientBase[GUID,DetailPageResult,LegistarData]Client to upload items from
LegistarData
- class granicus_archiver.aws.client.RGuidLegistarClient(config: Config, max_clips: int, legistar_data: _ModelT | None = None)[source]¶
Bases:
LegistarClientBase[REAL_GUID,RGuidDetailResult,RGuidLegistarData]Client to upload items from
RGuidLegistarData