session
¶
Session handling.
Classes:
-
BaseSession– -
Session–An email sending session. Ordinarily when deployed to Cloud Run or a similar hosting service,
BaseSession
¶
Session
¶
Session(
service_role_arn,
*,
impersonate_service_account=None,
role_session_name=None,
aws_region=None,
default_from_address=None
)
An email sending session. Ordinarily when deployed to Cloud Run or a similar hosting service, one need only provide the service role ARN. Other arguments are intended for special cases or when running locally.
Parameters:
-
(service_role_arn¶str) –AWS ARN of service-specific role which can send email for the service.
-
(impersonate_service_account¶Optional[str], default:None) –When deployed via Cloud Run or similar there is an "ambient" workload identity configured for the service. If you are running locally with your own account, you will need to impersonate a service account allowed to send email. If this is the case, pass the email formatted identifier here.
-
(role_session_name¶Optional[str], default:None) –Arbitrary string which appears in logs. Can be used to distinguish different email tasks within the same service. If not provided, a reasonable default will be used.
-
(aws_region¶Optional[str], default:None) –The AWS region used to send email. Ordinarily this will not need to be changed from the default value.
Methods:
-
for_service–Construct a session by fetching service configuration. Either the ambient workload identity
-
send_email–Send an email message using this session.
for_service
staticmethod
¶
for_service(
service_id,
*,
environment=None,
impersonate_service_account=None,
role_session_name=None
)
Construct a session by fetching service configuration. Either the ambient workload identity or the impersonated service account must have permission to fetch the service configuration.
Parameters:
-
(service_id¶str) –the id of the service as registered in the user notify service
-
(impersonate_service_account¶Optional[str], default:None) –email address of service account to impersonate if ambient workload identity is not to be used
-
(role_session_name¶Optional[str], default:None) –Arbitrary string which appears in logs. Can be used to distinguish different email tasks within the same service. If not provided, a reasonable default will be used.
-
(environment¶Optional[str], default:None) –which environment of the user notify service should be used. Unless you are actively developing the user notify service, leave this as the default value.