Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd5645b

Browse files
author
Aaron Gabriel Neyer
authored
cleanup: add turbo rep samples and fix spacing on fileio samples (googleapis#708)
* cleanup: add turbo rep samples and fix spacing on fileio samples * fix links * woops, missed that
1 parent cd241f7 commit fd5645b

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

samples/README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ for more detailed instructions.
6464
* [Create Bucket](#create-bucket)
6565
* [Create Bucket Class Location](#create-bucket-class-location)
6666
* [Create Bucket Notifications](#create-bucket-notifications)
67+
* [Create Bucket Turbo Replication](#create-bucket-turbo-replication)
6768
* [Create HMAC Key](#create-hmac-key)
6869
* [Deactivate HMAC Key](#deactivate-hmac-key)
6970
* [Define Bucket Website Configuration](#define-bucket-website-configuration)
@@ -88,8 +89,8 @@ for more detailed instructions.
8889
* [Enable Requester Pays](#enable-requester-pays)
8990
* [Enable Uniform Bucket Level Access](#enable-uniform-bucket-level-access)
9091
* [Enable Versioning](#enable-versioning)
91-
* [FileIO Write-Read] (#fileio-write-read)
92-
* [FileIO Pandas] (#fileio-pandas)
92+
* [FileIO Write-Read](#fileio-write-read)
93+
* [FileIO Pandas](#fileio-pandas)
9394
* [Generate Encryption Key](#generate-encryption-key)
9495
* [Generate Signed Post Policy V4](#generate-signed-post-policy-v4)
9596
* [Generate Signed Url V2](#generate-signed-url-v2)
@@ -103,6 +104,7 @@ for more detailed instructions.
103104
* [Get Public Access Prevention](#get-public-access-prevention)
104105
* [Get Requester Pays Status](#get-requester-pays-status)
105106
* [Get Retention Policy](#get-retention-policy)
107+
* [Get RPO](#get-rpo)
106108
* [Get Service Account](#get-service-account)
107109
* [Get Uniform Bucket Level Access](#get-uniform-bucket-level-access)
108110
* [List Buckets](#list-buckets)
@@ -139,6 +141,8 @@ for more detailed instructions.
139141
* [Set Metadata](#set-metadata)
140142
* [Set Public Access Prevention Enforced](#set-public-access-prevention-enforced)
141143
* [Set Public Access Prevention Inherited](#set-public-access-prevention-inherited)
144+
* [Set RPO Async Turbo](#set-rpo-async-turbo)
145+
* [Set RPO Default](#set-rpo-default)
142146
* [Set Retention Policy](#set-retention-policy)
143147
* [Set Temporary Hold](#set-temporary-hold)
144148
* [Upload Encrypted File](#upload-encrypted-file)
@@ -321,6 +325,15 @@ View the [source code](https://github.com/googleapis/python-storage/blob/main/sa
321325
322326
`python storage_create_bucket_notifications.py <BUCKET_NAME> <TOPIC_NAME>`
323327
328+
-----
329+
### Create Bucket Turbo Replication
330+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_create_bucket_turbo_replication.py,samples/README.md)
331+
332+
View the [source code](https://github.com/googleapis/python-storage/blob/main/samples/snippets/storage_create_bucket_turbo_replication.py). To run this sample:
333+
334+
335+
`python storage_create_bucket_turbo_replication.py <BUCKET_NAME>`
336+
324337
-----
325338
### Create HMAC Key
326339
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_create_hmac_key.py,samples/README.md)
@@ -672,6 +685,15 @@ View the [source code](https://github.com/googleapis/python-storage/blob/main/sa
672685
673686
`python storage_get_retention_policy.py <BUCKET_NAME>`
674687
688+
-----
689+
### Get RPO
690+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_get_rpo.py,samples/README.md)
691+
692+
View the [source code](https://github.com/googleapis/python-storage/blob/main/samples/snippets/storage_get_rpo.py). To run this sample:
693+
694+
695+
`python storage_get_rpo.py <BUCKET_NAME>`
696+
675697
-----
676698
### Get Service Account
677699
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_get_service_account.py,samples/README.md)
@@ -1005,6 +1027,25 @@ View the [source code](https://github.com/googleapis/python-storage/blob/main/sa
10051027
10061028
`python storage_set_retention_policy.py <BUCKET_NAME> <RETENTION_PERIOD>`
10071029
1030+
1031+
-----
1032+
### Set RPO Async Turbo
1033+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_set_rpo_async_turbo.py,samples/README.md)
1034+
1035+
View the [source code](https://github.com/googleapis/python-storage/blob/main/samples/snippets/storage_set_rpo_async_turbo.py). To run this sample:
1036+
1037+
1038+
`python storage_set_rpo_async_turbo.py <BUCKET_NAME>`
1039+
1040+
-----
1041+
### Set RPO Default
1042+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_set_rpo_default.py,samples/README.md)
1043+
1044+
View the [source code](https://github.com/googleapis/python-storage/blob/main/samples/snippets/storage_set_rpo_default.py). To run this sample:
1045+
1046+
1047+
`python storage_set_rpo_default.py <BUCKET_NAME>`
1048+
10081049
-----
10091050
### Set Temporary Hold
10101051
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-storage&page=editor&open_in_editor=samples/snippets/storage_set_temporary_hold.py,samples/README.md)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the 'License');
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import sys
18+
19+
"""Sample that creates a new bucket in a specified region
20+
"""
21+
22+
# [START storage_create_bucket_location]
23+
24+
from google.cloud import storage
25+
26+
27+
def create_bucket_location(bucket_name, bucket_location):
28+
"""Creates bucket in specified region."""
29+
# The ID of your GCS bucket
30+
# bucket_name = "my-bucket"
31+
# bucket_location = 'us-west1' # region
32+
# bucket_location = 'nam4' # dual-region
33+
# bucket_location = 'us' #multi-region
34+
35+
storage_client = storage.Client()
36+
bucket = storage_client.bucket(bucket_name)
37+
bucket.create(location=bucket_location)
38+
39+
print(f"{bucket.name} created in {bucket.location}.")
40+
41+
42+
# [END storage_create_bucket_location]
43+
44+
if __name__ == "__main__":
45+
create_bucket_location(bucket_name=sys.argv[1], bucket_location=sys.argv[2])

0 commit comments

Comments
 (0)