rs_server_catalog/utils.md
This library contains functions used in handling the user catalog.
add_prefix_link_landing_page(content, url)
Add the CATALOG_PREFIX to the landing page if it is not present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
dict
|
the landing page |
required |
url
|
str
|
the url |
required |
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
extract_owner_name_from_json_filter(json_filter)
Scans a CQL2 JSON filter and returns the associated owner name if it contains an "owner" property. Owner name must be in this kind of subpart of the filter: "args": [{"property": "owner"}, "toto"]}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_filter
|
Any
|
Filter to scan. Expected to be a dictionary (else returns None) |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str|None: owner name if there is one, None in any other case |
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
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 | |
extract_owner_name_from_text_filter(text_filter)
Scans a CQL2 text filter and returns the associated owner name if it contains an "owner" property. Owner name must be a field in this kind of filter: "width=2500 AND owner='toto'"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_filter
|
str
|
Text filter to scan |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str|None: owner name if there is one, None in any other case |
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get_temp_bucket_name(files_s3_key)
Retrieve the temporary bucket name from a list of S3 keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files_s3_key
|
list[str]
|
A list of S3 key strings. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The name of the temporary S3 bucket if valid, otherwise None. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If the S3 key does not match the expected pattern, or if multiple buckets are used. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
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 | |
get_token_for_pagination(items_dic)
Used to get the token to be used when calling functions from the stac-fastapi-pgstac object.
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
113 114 115 116 117 118 119 | |
headers_minus_content_length(response)
Returns response headers without Content-Length
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
122 123 124 | |
is_s3_path(s3_key)
Function to check if a string matches the S3 pattern
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
74 75 76 77 78 | |
verify_existing_item_from_catalog(method, item, content_id_str, user_collection_str)
Verify if an exisiting item from the catalog may be created or updated
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
The HTTP method used in the request (e.g., "POST", "PUT", "PATCH"). |
required |
item
|
dict
|
The item from the catalog to check. |
required |
content_id_str
|
str
|
The name of the item, used for generating an error message |
required |
user_collection_str
|
str
|
The collection identifier including the user. |
required |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If a POST request is made for an existing item, or if a PUT/PATCH request is made for a non-existent item. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/utils.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |