How to use the aiogoogle.models.MediaDownload function in aiogoogle

To help you get started, we’ve selected a few aiogoogle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omarryhan / aiogoogle / tests / test_units / test_client / test_request.py View on Github external
def test_request_constructor():
    req = Request(
        method='GET',
        url='https://example.com/api/v1/example_resource?example_query=example_arg',
        headers={'Authorization': 'Bearer asdasdasd'},
        json={'data': 'asasdasd'},
        media_upload=MediaUpload('asdasd'),
        media_download=MediaDownload('assda')
    )
github omarryhan / aiogoogle / aiogoogle / resource.py View on Github external
# Validate body
        if validate is True:
            body = (
                json if json is not None else data if data is not None else None
            )  # json or data or None
            if body is not None:
                self._validate_body(body)

        # Process download_file
        if download_file:
            if validate is True:
                if self.__getitem__("supportsMediaDownload") is not True:
                    raise ValidationError(
                        "download_file was provided while method doesn't support media download"
                    )
            media_download = MediaDownload(download_file)
        else:
            media_download = None

        # Process upload_file
        if upload_file:
            media_upload = self._build_upload_media(
                upload_file, uri, validate, fallback_url=url
            )
        else:
            media_upload = None

        return Request(
            method=self["httpMethod"],
            url=uri,
            batch_url=self._batch_url,
            data=data,
github omarryhan / aiogoogle / aiogoogle / method.py View on Github external
'\nThis will validate agains the $request key in this method\'s '
                            'discovery document')  # This raises a TypeError instead of a ValidationError because 
                                                   # it will probably make your session raise an error if it passes.

        # Validate body
        if validate is True:
            body = json if json is not None else data if data is not None else None
            if isinstance(body, dict):
                self._validate_body(body)

        # Process download_file
        if download_file:
            if validate is True:
                if getattr(self, 'supportsMediaDownload', None) is not True:
                    raise ValidationError('download_file was provided while method doesn\'t support media download')
            media_download = MediaDownload(download_file)
        else:
            media_download = None

        # Process upload_file
        if upload_file:
            media_upload = self._build_upload_media(upload_file)
        else:
            media_upload = None

        return Request(
            method=self.httpMethod,
            url=uri,
            data=data,
            json=json,
            timeout=timeout,
            media_download=media_download,