Skip to content

get_whats_app_message_media async

get_whats_app_message_media(
    media_id: WhatsAppMediaId,
    origination_phone_number_id: WhatsAppPhoneNumberId,
    *,
    config_overrides: Optional[AsyncSocialMessagingClientConfig] = None,
    metadata_only: Optional[bool] = None,
    destination_s3_presigned_url: Optional[S3PresignedUrl] = None,
    destination_s3_file: Optional[S3File] = None,
) -> GetWhatsAppMessageMediaOutput

Get a media file from the WhatsApp service. On successful completion the media file is retrieved from Meta and stored in the specified Amazon S3 bucket. Use either destinationS3File or destinationS3PresignedUrl for the destination. If both are used then an InvalidParameterException is returned.

Parameters:

  • media_id (WhatsAppMediaId) –

    The unique identifier for the media file.

  • origination_phone_number_id (WhatsAppPhoneNumberId) –

    The unique identifier of the originating phone number for the WhatsApp message media. The phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.

  • metadata_only (Optional[bool], default: None ) –

    Set to True to get only the metadata for the file.

  • destination_s3_presigned_url (Optional[S3PresignedUrl], default: None ) –

    The presign url of the media file.

  • destination_s3_file (Optional[S3File], default: None ) –

    The bucketName and key of the S3 media file.

Raises:

Source code in docs_src/capo_socialmessaging/_services/async_social_messaging.py
async def get_whats_app_message_media(
    self,
    media_id: "capo_socialmessaging.types.whats_app_media_id.WhatsAppMediaId",
    origination_phone_number_id: "capo_socialmessaging.types.whats_app_phone_number_id.WhatsAppPhoneNumberId",
    *,
    config_overrides: Optional[AsyncSocialMessagingClientConfig] = None,
    metadata_only: Optional[bool] = None,
    destination_s3_presigned_url: Optional[
        "capo_socialmessaging.types.s3_presigned_url.S3PresignedUrl"
    ] = None,
    destination_s3_file: Optional[
        "capo_socialmessaging.types.s3_file.S3File"
    ] = None,
) -> "capo_socialmessaging.types.get_whats_app_message_media_output.GetWhatsAppMessageMediaOutput":
    """<p>Get a media file from the WhatsApp service. On successful completion the media file is retrieved from Meta and stored in the specified Amazon S3 bucket. Use either <code>destinationS3File</code> or <code>destinationS3PresignedUrl</code> for the destination. If both are used then an <code>InvalidParameterException</code> is returned.</p>

    Args:
        media_id: <p>The unique identifier for the media file.</p>
        origination_phone_number_id: <p>The unique identifier of the originating phone number for the WhatsApp message media. The phone number identifiers are formatted as <code>phone-number-id-01234567890123456789012345678901</code>. Use <a href="https://docs.aws.amazon.com/social-messaging/latest/APIReference/API_GetLinkedWhatsAppBusinessAccount.html">GetLinkedWhatsAppBusinessAccount</a> to find a phone number's id.</p>
        metadata_only: <p>Set to <code>True</code> to get only the metadata for the file.</p>
        destination_s3_presigned_url: <p>The presign url of the media file.</p>
        destination_s3_file: <p>The <code>bucketName</code> and <code>key</code> of the S3 media file.</p>

    Raises:
        capo_socialmessaging.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.validation_exception.ValidationException: <p>The request contains an invalid parameter value. </p>
        capo_socialmessaging.errors.access_denied_by_meta_exception.AccessDeniedByMetaException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.dependency_exception.DependencyException: <p>Thrown when performing an action because a dependency would be broken.</p>
        capo_socialmessaging.errors.internal_service_exception.InternalServiceException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
        capo_socialmessaging.errors.invalid_parameters_exception.InvalidParametersException: <p>One or more parameters provided to the action are not valid.</p>
        capo_socialmessaging.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource was not found.</p>
        capo_socialmessaging.errors.throttled_request_exception.ThrottledRequestException: <p>The request was denied due to request throttling.</p>
        capo_socialmessaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_socialmessaging.types.get_whats_app_message_media_input.GetWhatsAppMessageMediaInput]",
    ) -> AsyncOperationResponse[
        "capo_socialmessaging.types.get_whats_app_message_media_output.GetWhatsAppMessageMediaOutput"
    ]:
        import capo_socialmessaging._operations.social_messaging.get_whats_app_message_media

        (
            output,
            http_response,
        ) = await capo_socialmessaging._operations.social_messaging.get_whats_app_message_media.async_get_whats_app_message_media(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_socialmessaging.types.get_whats_app_message_media_input.GetWhatsAppMessageMediaInput",
    ) -> dict[str, Any]:
        import capo_socialmessaging.types.get_whats_app_message_media_input

        return capo_socialmessaging.types.get_whats_app_message_media_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetWhatsAppMessageMedia", redact_input=_redact_input),
    )
    input_: capo_socialmessaging.types.get_whats_app_message_media_input.GetWhatsAppMessageMediaInput = {
        "media_id": media_id,
        "origination_phone_number_id": origination_phone_number_id,
    }
    if metadata_only is not None:
        input_["metadata_only"] = metadata_only
    if destination_s3_presigned_url is not None:
        input_["destination_s3_presigned_url"] = destination_s3_presigned_url
    if destination_s3_file is not None:
        input_["destination_s3_file"] = destination_s3_file

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output