def _upload(self, archive, region):
        """Upload function source and return source url
        """
        # Generate source upload url
        url = self.client.execute_command(
            'generateUploadUrl',
            {'parent': 'projects/{}/locations/{}'.format(
                self.session.get_default_project(),
                region)}).get('uploadUrl')
        log.debug("uploading function code %s", url)
        http = self._get_http_client(self.client)
        headers, response = http.request(
            url, method='PUT',
            headers={
                'content-type': 'application/zip',
                'Content-Length': '%d' % archive.size,
                'x-goog-content-length-range': '0,104857600'
            },
            body=open(archive.path, 'rb')
        )
        log.info("function code uploaded")
        if headers['status'] != '200':
            raise RuntimeError("%s\n%s" % (headers, response))
        return url
def _upload ( self , archive , region ) : url = self . client . execute_command ( 'generateUploadUrl' , { 'parent' : 'projects/{}/locations/{}' . format ( self . session . get_default_project ( ) , region ) } ) . get ( 'uploadUrl' ) log . debug ( "uploading function code %s" , url ) http = self . _get_http_client ( self . client ) headers , response = http . request ( url , method = 'PUT' , headers = { 'content-type' : 'application/zip' , 'Content-Length' : '%d' % archive . size , 'x-goog-content-length-range' : '0,104857600' } , body = open ( archive . path , 'rb' ) ) log . info ( "function code uploaded" ) if headers [ 'status' ] != '200' : raise RuntimeError ( "%s\n%s" % ( headers , response ) ) return url
Upload function source and return source url