rs_common/utils.md¶
This module is used to share common functions between apis
AuthInfo
dataclass
¶
User authentication information in Keycloak.
Source code in docs/rs-client-libraries/rs_common/utils.py
create_valcover_filter(start_datetime, end_datetime, product_type)
¶
Creates a ValCover filter from the input values to be used in flows
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_datetime
|
datetime | str
|
Start datetime for the time interval used to filter the files |
required |
end_datetime
|
datetime | str
|
End datetime for the time interval used to filter the files |
required |
product_type
|
str
|
Auxiliary file type wanted |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
ValCover filter |
Source code in docs/rs-client-libraries/rs_common/utils.py
env_bool(var, default)
¶
Return True if an environemnt variable is set to 1, true or yes (case insensitive). Return False if set to 0, false or no (case insensitive). Return the default value if not set or set to a different value.
Source code in docs/rs-client-libraries/rs_common/utils.py
extract_tar(file_path, extract_to)
¶
Extract a TAR-compatible archive into the target directory.
Returns:
| Type | Description |
|---|---|
tuple[int, list[str]]
|
Tuple[int, List[str]]: (count of extracted files, list of extracted file paths) |
Source code in docs/rs-client-libraries/rs_common/utils.py
extract_zip(zip_path, extract_to)
¶
Extract a ZIP archive into the target directory.
Source code in docs/rs-client-libraries/rs_common/utils.py
get_href_service(rs_server_href, env_var)
¶
Get specific href link.
Source code in docs/rs-client-libraries/rs_common/utils.py
get_upload_prefix(asset_href, asset_name)
¶
Return the S3 prefix where extracted content should be uploaded.
Source code in docs/rs-client-libraries/rs_common/utils.py
normalize_extract_dir(extract_dir)
¶
Return the directory that should be used as the upload root.
If the extraction produced a single top-level directory, descend into it to avoid creating an unnecessary extra folder level in S3.
Source code in docs/rs-client-libraries/rs_common/utils.py
read_response_error(response)
¶
Read and return an HTTP response error detail.
Source code in docs/rs-client-libraries/rs_common/utils.py
recursive_extract(folder)
¶
Extract nested TAR-compatible archives found anywhere under folder.
Source code in docs/rs-client-libraries/rs_common/utils.py
strftime_millis(date)
¶
strip_archive_suffix(name)
¶
Return the asset name without its supported archive suffix.