Utils
Utility functions for Provider app.
- smarter.apps.provider.utils.get_google_maps_api_key()[source]
Get the Google Maps API key from its Smarter Secret,
google_maps_api_key, the Smarter admin’s.The Secret is the key’s only source: the init Job creates it from the platform’s bootstrap secrets (
initialize_bootstrap_secrets, issue #1099), and no service reads an environment variable for it.
- smarter.apps.provider.utils.get_google_service_account_bearer_token()[source]
Get a Google service account bearer token.
- smarter.apps.provider.utils.get_model_verification_for_type(provider_model, verification_type)[source]
Get the model verification for a specific type, creating it if it does not exist.
- Parameters:
provider_model (
ProviderModel) – The provider model.verification_type (
ProviderModelVerificationTypes) – The kind of verification.
- Return type:
- Returns:
The existing or new ProviderModelVerification.
- smarter.apps.provider.utils.get_provider_verification_for_type(provider, verification_type)[source]
Get the provider verification for a specific type, creating it if it does not exist.
- Parameters:
provider (
Provider) – The provider.verification_type (
ProviderVerificationTypes) – The kind of verification.
- Return type:
- Returns:
The existing or new ProviderVerification.
- smarter.apps.provider.utils.set_model_verification(provider_model_verification, is_successful, **kwargs)[source]
Save the model verification’s outcome, and send the matching signal.
Sends
model_verification_successormodel_verification_failure.- Parameters:
provider_model_verification (
ProviderModelVerification) – The verification to update.is_successful (
bool) – Whether the verification passed.kwargs – Not used.
- Return type:
- smarter.apps.provider.utils.set_provider_verification(provider_verification, is_successful, **kwargs)[source]
Save the provider verification’s outcome, and send the matching signal.
Sends
provider_verification_successorprovider_verification_failure.- Parameters:
provider_verification (
ProviderVerification) – The verification to update.is_successful (
bool) – Whether the verification passed.kwargs – Not used.
- Return type:
- smarter.apps.provider.utils.should_log(level)[source]
Check if logging should be done based on the waffle switch.