Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ replacements:
- paths: [
packages/google-cloud-bigtable/google/cloud/bigtable_admin_v2/__init__.py
]
before: '"UpdateTableRequest",\n\)\n\z'
before: '"UpdateTableRequest",\n\)\n\Z'
after: |
"UpdateTableRequest",
)
Expand All @@ -259,7 +259,7 @@ replacements:
- paths: [
packages/google-cloud-bigtable/google/cloud/bigtable_admin/__init__.py
]
before: '"Type",\n\)\n\z'
before: '"Type",\n\)\n\Z'
after: |
"Type",
)
Expand Down
1 change: 0 additions & 1 deletion librarian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,6 @@ libraries:
keep:
- CHANGELOG.md
- docs/CHANGELOG.md
skip_generate: true
python:
library_type: GAPIC_COMBO
opt_args_by_api:
Expand Down
85 changes: 10 additions & 75 deletions packages/google-cloud-bigtable/.repo-metadata.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,16 @@
{
"name": "bigtable",
"name_pretty": "Google Cloud Bigtable",
"api_description": "is Google's NoSQL Big Data database service. It's the\nsame database that powers many core Google services, including Search,\nAnalytics, Maps, and Gmail.",
"product_documentation": "https://cloud.google.com/bigtable",
"api_id": "bigtable.googleapis.com",
"api_shortname": "bigtable",
"client_documentation": "https://cloud.google.com/python/docs/reference/bigtable/latest",
"default_version": "v2",
"distribution_name": "google-cloud-bigtable",
"issue_tracker": "https://issuetracker.google.com/savedsearches/559777",
"release_level": "stable",
"language": "python",
"library_type": "GAPIC_COMBO",
"repo": "googleapis/google-cloud-python",
"distribution_name": "google-cloud-bigtable",
"api_id": "bigtable.googleapis.com",
"requires_billing": true,
"samples": [
{
"name": "Hello World in Cloud Bigtable",
"description": "Demonstrates how to connect to Cloud Bigtable and run some basic operations. More information available at: https://cloud.google.com/bigtable/docs/samples-python-hello",
"file": "main.py",
"runnable": true,
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
"override_path": "hello"
},
{
"name": "Hello World using HappyBase",
"description": "This sample demonstrates using the Google Cloud Client Library HappyBase package, an implementation of the HappyBase API to connect to and interact with Cloud Bigtable. More information available at: https://cloud.google.com/bigtable/docs/samples-python-hello-happybase",
"file": "main.py",
"runnable": true,
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
"override_path": "hello_happybase"
},
{
"name": "cbt Command Demonstration",
"description": "This page explains how to use the cbt command to connect to a Cloud Bigtable instance, perform basic administrative tasks, and read and write data in a table. More information about this quickstart is available at https://cloud.google.com/bigtable/docs/quickstart-cbt",
"file": "instanceadmin.py",
"runnable": true,
"custom_content": "<pre>usage: instanceadmin.py [-h] [run] [dev-instance] [del-instance] [add-cluster] [del-cluster] project_id instance_id cluster_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
"override_path": "instanceadmin"
},
{
"name": "Metric Scaler",
"description": "This sample demonstrates how to use Stackdriver Monitoring to scale Cloud Bigtable based on CPU usage.",
"file": "metricscaler.py",
"runnable": true,
"custom_content": "<pre>usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD] [--low_cpu_threshold LOW_CPU_THRESHOLD] [--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP] bigtable_instance bigtable_cluster<br>usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[--low_cpu_threshold LOW_CPU_THRESHOLD] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bigtable_instance bigtable_cluster <br><br> <br>Scales Cloud Bigtable clusters based on CPU usage. <br><br> <br>positional arguments: <br>&nbsp; bigtable_instance &nbsp; &nbsp; ID of the Cloud Bigtable instance to connect to. <br>&nbsp; bigtable_cluster &nbsp; &nbsp; &nbsp;ID of the Cloud Bigtable cluster to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;show this help message and exit <br>&nbsp; --high_cpu_threshold HIGH_CPU_THRESHOLD <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Cloud Bigtable CPU usage is above this threshold, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scale up <br>&nbsp; --low_cpu_threshold LOW_CPU_THRESHOLD <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Cloud Bigtable CPU usage is below this threshold, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scale down <br>&nbsp; --short_sleep SHORT_SLEEP <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How long to sleep in seconds between checking metrics <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; after no scale operation <br>&nbsp; --long_sleep LONG_SLEEP <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How long to sleep in seconds between checking metrics <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; after a scaling operation</pre>",
"override_path": "metricscaler"
},
{
"name": "Quickstart",
"description": "Demonstrates of Cloud Bigtable. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection.",
"file": "main.py",
"runnable": true,
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Existing table used in the quickstart. (default: my-table)</pre>",
"override_path": "quickstart"
},
{
"name": "Quickstart using HappyBase",
"description": "Demonstrates of Cloud Bigtable using HappyBase. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection.",
"file": "main.py",
"runnable": true,
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>usage: main.py [-h] [--table TABLE] project_id instance_id <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Existing table used in the quickstart. (default: my-table)</pre>",
"override_path": "quickstart_happybase"
},
{
"name": "Snippets",
"description": "This folder contains snippets for Python Cloud Bigtable.",
"override_path": "snippets"
},
{
"name": "Table Admin",
"description": "Demonstrates how to connect to Cloud Bigtable and run some basic operations.",
"file": "tableadmin.py",
"runnable": true,
"custom_content": "<pre>usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id <br><br> <br>Demonstrates how to connect to Cloud Bigtable and run some basic operations. <br>Prerequisites: - Create a Cloud Bigtable cluster. <br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google <br>Application Default Credentials. <br>https://developers.google.com/identity/protocols/application-default- <br>credentials <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
"override_path": "tableadmin"
}
],
"default_version": "v2",
"codeowner_team": "@googleapis/api-bigtable @googleapis/api-bigtable-partners",
"api_shortname": "bigtable"
}
"name": "bigtable",
"name_pretty": "Google Cloud Bigtable",
"product_documentation": "https://cloud.google.com/bigtable",
"release_level": "stable",
"repo": "googleapis/google-cloud-python"
}
54 changes: 21 additions & 33 deletions packages/google-cloud-bigtable/docs/classic_client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@
"""

from datetime import datetime, timezone
import pytest

from google.api_core.exceptions import DeadlineExceeded
from google.api_core.exceptions import NotFound
from google.api_core.exceptions import TooManyRequests
from google.api_core.exceptions import ServiceUnavailable
from test_utils.system import unique_resource_id
import pytest
from google.api_core.exceptions import (
DeadlineExceeded,
NotFound,
ServiceUnavailable,
TooManyRequests,
)
from test_utils.retry import RetryErrors
from test_utils.system import unique_resource_id


from google.cloud.bigtable import Client
from google.cloud.bigtable import enums

from google.cloud.bigtable import Client, enums

UNIQUE_SUFFIX = unique_resource_id("-")
INSTANCE_ID = "snippet-tests" + UNIQUE_SUFFIX
Expand All @@ -57,9 +56,7 @@
STORAGE_TYPE = enums.StorageType.SSD
LABEL_KEY = "python-snippet"
LABEL_STAMP = (
datetime.now(timezone.utc)
.replace(microsecond=0)
.strftime("%Y-%m-%dt%H-%M-%S")
datetime.now(timezone.utc).replace(microsecond=0).strftime("%Y-%m-%dt%H-%M-%S")
)
LABELS = {LABEL_KEY: str(LABEL_STAMP)}
INSTANCES_TO_DELETE = []
Expand Down Expand Up @@ -110,8 +107,7 @@ def teardown_module():

def test_bigtable_create_instance():
# [START bigtable_api_create_prod_instance]
from google.cloud.bigtable import Client
from google.cloud.bigtable import enums
from google.cloud.bigtable import Client, enums

my_instance_id = "inst-my-" + UNIQUE_SUFFIX
my_cluster_id = "clus-my-" + UNIQUE_SUFFIX
Expand Down Expand Up @@ -144,8 +140,7 @@ def test_bigtable_create_instance():

def test_bigtable_create_additional_cluster():
# [START bigtable_api_create_cluster]
from google.cloud.bigtable import Client
from google.cloud.bigtable import enums
from google.cloud.bigtable import Client, enums

# Assuming that there is an existing instance with `INSTANCE_ID`
# on the server already.
Expand Down Expand Up @@ -181,8 +176,7 @@ def test_bigtable_create_reload_delete_app_profile():
import re

# [START bigtable_api_create_app_profile]
from google.cloud.bigtable import Client
from google.cloud.bigtable import enums
from google.cloud.bigtable import Client, enums

routing_policy_type = enums.RoutingPolicyType.ANY

Expand Down Expand Up @@ -422,10 +416,9 @@ def test_bigtable_cluster_disable_autoscaling():

def test_bigtable_create_table():
# [START bigtable_api_create_table]
from google.api_core import exceptions
from google.api_core import retry
from google.cloud.bigtable import Client
from google.cloud.bigtable import column_family
from google.api_core import exceptions, retry

from google.cloud.bigtable import Client, column_family

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand Down Expand Up @@ -547,8 +540,7 @@ def test_bigtable_set_iam_policy_then_get_iam_policy():

# [START bigtable_api_set_iam_policy]
from google.cloud.bigtable import Client
from google.cloud.bigtable.policy import Policy
from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE
from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE, Policy

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand Down Expand Up @@ -615,8 +607,7 @@ def test_bigtable_admins_policy():

# [START bigtable_api_admins_policy]
from google.cloud.bigtable import Client
from google.cloud.bigtable.policy import Policy
from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE
from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE, Policy

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand All @@ -636,8 +627,7 @@ def test_bigtable_readers_policy():

# [START bigtable_api_readers_policy]
from google.cloud.bigtable import Client
from google.cloud.bigtable.policy import Policy
from google.cloud.bigtable.policy import BIGTABLE_READER_ROLE
from google.cloud.bigtable.policy import BIGTABLE_READER_ROLE, Policy

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand All @@ -657,8 +647,7 @@ def test_bigtable_users_policy():

# [START bigtable_api_users_policy]
from google.cloud.bigtable import Client
from google.cloud.bigtable.policy import Policy
from google.cloud.bigtable.policy import BIGTABLE_USER_ROLE
from google.cloud.bigtable.policy import BIGTABLE_USER_ROLE, Policy

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand All @@ -678,8 +667,7 @@ def test_bigtable_viewers_policy():

# [START bigtable_api_viewers_policy]
from google.cloud.bigtable import Client
from google.cloud.bigtable.policy import Policy
from google.cloud.bigtable.policy import BIGTABLE_VIEWER_ROLE
from google.cloud.bigtable.policy import BIGTABLE_VIEWER_ROLE, Policy

client = Client(admin=True)
instance = client.instance(INSTANCE_ID)
Expand Down
Loading
Loading