As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Batches

Batch updates / deletes of storage buckets / blobs.

See https://cloud.google.com/storage/docs/json_api/v1/how-tos/batch

class google.cloud.storage.batch.Batch(client)[source]

Bases: google.cloud.storage._http.Connection

Proxy an underlying connection, batching up change operations.

Parameters

client (google.cloud.storage.client.Client) – The client to use for making connections.

current()[source]

Return the topmost batch, or None.

finish()[source]

Submit a single multipart/mixed request with deferred requests.

Return type

list of tuples

Returns

one (headers, payload) tuple per deferred request.

class google.cloud.storage.batch.MIMEApplicationHTTP(method, uri, headers, body)[source]

Bases: email.mime.application.MIMEApplication

MIME type for application/http.

Constructs payload from headers and body

Parameters
  • method (str) – HTTP method

  • uri (str) – URI for HTTP request

  • headers (dict) – HTTP headers

  • body (str) – (Optional) HTTP payload

Create an application/* type MIME document.

_data is a string containing the raw application data.

_subtype is the MIME content type subtype, defaulting to ‘octet-stream’.

_encoder is a function which will perform the actual encoding for transport of the application data, defaulting to base64 encoding.

Any additional keyword arguments are passed to the base class constructor, which turns them into parameters on the Content-Type header.