Add the SAS token to the URL Parameters ---------- account : str The account name. container : str The container name. sasToken : str The SAS token. filepath : str The file path. apiType : ApiType The type of the api Retu
(account, container, sasToken, filepath, apiType: ApiType)
| 75 | |
| 76 | |
| 77 | def add_URL_sasToken(account, container, sasToken, filepath, apiType: ApiType): |
| 78 | """ |
| 79 | Add the SAS token to the URL |
| 80 | |
| 81 | Parameters |
| 82 | ---------- |
| 83 | account : str |
| 84 | The account name. |
| 85 | container : str |
| 86 | The container name. |
| 87 | sasToken : str |
| 88 | The SAS token. |
| 89 | filepath : str |
| 90 | The file path. |
| 91 | apiType : ApiType |
| 92 | The type of the api |
| 93 | |
| 94 | Returns |
| 95 | ------- |
| 96 | SecretStr |
| 97 | The URL with SAS token |
| 98 | """ |
| 99 | |
| 100 | match apiType: |
| 101 | case ApiType.THUMB if filepath and filepath.strip(): |
| 102 | bloburl = ( |
| 103 | f"https://{account}.blob.core.windows.net/{container}/{filepath}.jpg" |
| 104 | ) |
| 105 | case ApiType.IMAGE: |
| 106 | bloburl = f"https://{account}.blob.core.windows.net/{container}/datasource_thumbnail.jpg" |
| 107 | case ApiType.IQDATA if filepath and filepath.strip(): |
| 108 | bloburl = f"https://{account}.blob.core.windows.net/{container}/{filepath}.sigmf-data" |
| 109 | case ApiType.METADATA if filepath and filepath.strip(): |
| 110 | bloburl = f"https://{account}.blob.core.windows.net/{container}/{filepath}.sigmf-meta" |
| 111 | case _: |
| 112 | raise ValueError("Invalid ApiType value") |
| 113 | |
| 114 | if sasToken is not None and sasToken != "": |
| 115 | # linter fix for error: "get_secret_value" is not a known member of "None" (reportOptionalMemberAccess) |
| 116 | x = decrypt(sasToken) |
| 117 | y = "" |
| 118 | if x is not None: |
| 119 | y = x.get_secret_value() |
| 120 | api_URL_sasToken = SecretStr(bloburl + "?" + y) |
| 121 | else: |
| 122 | api_URL_sasToken = SecretStr(bloburl) |
| 123 | |
| 124 | return api_URL_sasToken |
no test coverage detected