question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Bucket.location setter

See original GitHub issue

I was trying to change location of the bucket in Storage, but everything gets updated apart from location. It looks like the data is being sent through API, but are not persisted?

Code example

storage_client = StorageClient()
bucket = storage_client.create_bucket(name)
bucket.storage_class = 'MULTI_REGIONAL'
bucket.location = 'EU' # tried 'eu' as well
bucket.labels = {
     'project': 'etl-transformer',
     'group': 'etl',
}
bucket.patch()
# update_properties printed in _PropertyMixin:patch
{
    'labels': {
        'project': 'etl-transformer',
        'group': 'etl'
    },
    'storageClass': 'MULTI_REGIONAL',
    'location': 'EU'
}

# I checked here even dump in requests package to be sure it's being passed to the http object

# api_reponse
{
    u 'labels': {
      u 'project': u 'etl-transformer',
      u 'group': u 'etl'
    },
    u 'location': u 'US',
    u 'storageClass': u 'MULTI_REGIONAL'
}

I know that documentation doesn’t say that location attribute is a setter, but under the hood it’s a _scalar_property which is appended to changed properties and according to json API, location is writable:

https://cloud.google.com/storage/docs/json_api/v1/buckets

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
frankyncommented, Apr 13, 2018

Hi @gastlich,

Could you try the following instead:

# Imports the Google Cloud client library
from google.cloud import storage

# Instantiates a client
storage_client = storage.Client()

# The name for the new bucket
bucket_name = 'bucket-name'

# Create a new bucket object
bucket = storage_client.bucket(bucket_name)

# Set location
bucket.location = "EU"

# Set storage class
bucket.storage_class = "MULTI_REGIONAL"

# Create bucket
bucket.create()
0reactions
tseavercommented, Aug 28, 2018

Closed via #5808.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GetBucketLocation - Amazon Simple Storage Service
Returns the Region the bucket resides in. You set the bucket's Region using the LocationConstraint request parameter in a CreateBucket request.
Read more >
Class Bucket (2.7.0) | Python client library - Google Cloud
A sequence of mappings describing each CORS policy. data_locations. Retrieve the list of regional locations for custom dual-region buckets. See https://cloud.
Read more >
AWS S3 input | Filebeat Reference [8.5] - Elastic
Key and S3.Bucket.Name properties must be set (using the provided setters). The other properties will be used as metadata in the resulting event...
Read more >
Creating a bucket - Amazon Simple Storage Service
When you create a bucket, you must choose a bucket name and Region. You can optionally choose other storage management options for the...
Read more >
Fake GPS location - Apps on Google Play
Teleport your phone to any place in the world with two clicks! This app sets up fake GPS location so every other app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found