您可以构建基于 AWS python3+ 的 AWS Lambda 以及 AWS Step Functions。
import boto3
work_docs_client = boto3.client('workdocs') # Change aws connection parameters as per your setup
def lambda_handler(event, context):
# Call share_document_work_docs(resource_id, recipient_id) based on your conditions/checks
return None # change this as per your use-case
# This will add the permissions to the document to share
def share_document_work_docs(resource_id, recipient_id):
principals = [{'Id': recipient_id, 'Type': 'USER', 'Role': 'VIEWER'}] # change this as per your use-case
share_doc_response = work_docs_client.add_resource_permissions(
ResourceId=resource_id,
Principals=principals,
NotificationOptions={
'SendEmail': True,
'EmailMessage': 'Your message here',
} # change NotificationOptions as per your use-case
)
return share_doc_response